WordPress.org

Ready to get started?Download WordPress

Forums

Autoptimize
[resolved] Expires/Max Age compatibility with SuperCache (87 posts)

  1. hughforsyth
    Member
    Posted 5 months ago #

    Hi Frank,

    I've got a small compatibility issue with SuperCache. Is there any way to specify a different directory for the cache files?

    I recently updated to 1.70 and enabled the "Save aggregated script/css as static files" which I really like? I've now switched this off.

    The problem is that the max age was being set to 3 seconds. This ws being set by Supercache which adds the following .htaccess file to /wp-content/cache/ directory (and therefore /wp-content/cache/autoptimize).

    # BEGIN supercache
    <IfModule mod_mime.c>
    <FilesMatch "\.html\.gz$">
    ForceType text/html
    FileETag None
    </FilesMatch>
    AddEncoding gzip .gz
    AddType text/html .gz
    </IfModule>
    <IfModule mod_deflate.c>
    SetEnvIfNoCase Request_URI \.gz$ no-gzip
    </IfModule>
    <IfModule mod_headers.c>
    Header set Vary "Accept-Encoding, Cookie"
    Header set Cache-Control 'max-age=3, must-revalidate'
    </IfModule>
    <IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType text/html A3
    </IfModule>

    # END supercache

    It's not a fault with your plugin and maybe SuperCache should put the .htaccess in /wp-content/cache/supercache/. But an easy fix would be for me to move the Autoptimize folder to /public_html/wp-content/autoptimize.

    I've tried worked around this by adding a .htaccess file to /public_html/wp-content/cache/autoptimize. This worked but got deleted whenever I purged the Autoptimize cache.

    I've now switched back to dynamic but it would be nice to switch it back on..

    Thank you for your plugin. It's great and the only minify I've ever been able to get to work well.

    The site is http://www.unitedworldschools.org/

    Thanks

    http://wordpress.org/plugins/autoptimize/

  2. futtta
    Member
    Plugin Author

    Posted 5 months ago #

    This is really interesting! didn't know wp super cache forces the validity for all mime-types to a measly 3 seconds (I'll ask Donncha).

    I'll think about how to solve that for a next version, but guess you could just change the hardcoded path inside wp-content/plugins/autoptimize/autoptimize.php on lines 20 and 21 for now?

  3. futtta
    Member
    Plugin Author

    Posted 5 months ago #

    got confirmation from donncha (wp super cache developer) that this indeed is a small bug; the figure was supposed to be 3600 (1hour), not 3 (3 seconds). he just pushed out a new version yesterday, and that one still has this bug. a new version isn't planned (except if critical bugs).

    I'll probably create 1.7.1 for beginning of november to include a .htaccess in wp-content/cache/autoptimize, to override the wp super cache one in wp-content/cache.

    a temp fix (on your side) could also be to open wp-content/plugins/wp-super-cache/wp-cache.php and on line 2852 change

    $gziprules .= "<IfModule mod_headers.c>\n  Header set Vary \"Accept-Encoding, Cookie\"\n  Header set Cache-Control 'max-age=3, must-revalidate'\n</IfModule>\n";

    into

    $gziprules .= "<IfModule mod_headers.c>\n  Header set Vary \"Accept-Encoding, Cookie\"\n  Header set Cache-Control 'max-age=3600, must-revalidate'\n</IfModule>\n";

    clear the wp super cache (check if .htaccess is gone) and then the new .htaccess should contain the correct header.

    hope this helps,
    frank

  4. hughforsyth
    Member
    Posted 5 months ago #

    Thanks so much Frank.

    I'll try both updating the super cache wp-cache.php. and moving the autoptimize folder.

    For information, I also removed the "cookie" part of the vary-encoding the .htaccess I tried in /wp-content/cache/autoptimize. I might be wrong, but I can't think of any reason whey the javascript and CSS you minify would ever need to vary by cookie.

    <IfModule mod_headers.c>
    Header set Vary "Accept-Encoding"
    Header set Cache-Control 'max-age=604800, must-revalidate'
    </IfModule>

    Thanks
    Hugh

  5. hughforsyth
    Member
    Posted 5 months ago #

    Thanks Frank, the update to wp-content/plugins/wp-super-cache/wp-cache.php has worked.

    I did need to manually delete /wp-content/cache/.htaccess as clearing the SuperCache cache did not remove it. But SuperCache did create it with the new value.

    Thanks again.
    Hugh

  6. Hamed.T
    Member
    Posted 5 months ago #

    is my "B" rank on webpagetest because of this bug?
    look at my test result link
    it's show me the main page cached for 3 seconds !
    after i editing the wp-cache.php and delete .htaccess file nothing happen even .htaccess file doesn't created again...

  7. Hamed.T
    Member
    Posted 5 months ago #

    it's solved! just a little mistake...
    thank you frank you are a life saver this problem make me confused for three month and i didn't know how can i fix it after i see this topic, thank you again <3
    new test result link

  8. jronder
    Member
    Posted 5 months ago #

    Thank you for this, sorry could you perhaps specify what you mean by: clear the wp super cache (check if .htaccess is gone) and then the new .htaccess should contain the correct header.

    Does that mean I should uninstall it and instal again?

    Also can you please explain how this could affect the site?

    Thank you very much!

  9. futtta
    Member
    Plugin Author

    Posted 5 months ago #

    hi jronder; you need to make the change in wp-content/plugins/wp-super-cache/wp-cache.php on line 285 and then remove .htaccess in wp-content/cache, that should be it.

  10. jronder
    Member
    Posted 5 months ago #

    Thank you Futta,

    On line 285?? initially you wrote 2852.

    You know I am very new to this and I realy do not want is to screw up something more then it is already:-(

  11. jronder
    Member
    Posted 5 months ago #

    I found it, so I guess you meant 2852. Also when I clicked the edit code and I found the line 2852 and want to changed that number from 3(which is in blue)to 3600, it is typing in gray and does not look like it is correct thing. Am I digging into correct file??

    Do I need to replace the whole line or just changed the number?

  12. futtta
    Member
    Plugin Author

    Posted 5 months ago #

    if you are in the right file (wp-content/plugins/wp-super-cache/wp-cache.php) on line 2852 (indeed, my bad) and you see

    $gziprules .= "<IfModule mod_headers.c>\n  Header set Vary \"Accept-Encoding, Cookie\"\n  Header set Cache-Control 'max-age=3, must-revalidate'\n</IfModule>\n";

    then you can safely replace
    'max-age=3,must-revalidate'
    in that line into
    'max-age=3600,must-revalidate'

    and save your changes. do take care not to change anything else though, just add "600" after the 3 and before the comma.

  13. jronder
    Member
    Posted 5 months ago #

    Thank you very much Futta. I did it.
    And now the new .htaccess file comes there itself? Sorry if this stupid question.

    I have there also these files, no clue what is it, but should I delte it also?
    wp-cache-ce5fbeeda620a23430bf812a2f841a40.html
    wp-cache-a725f60fed0c4bf82fa63ed380ee873c.html
    wp-cache-959a0cc076e64c9d0c6843474b603966.html

    Thank you very much Futta, perhaps you come one day to Diani beach and I can at least take you for a drink:-)

  14. jronder
    Member
    Posted 5 months ago #

    Before I made change from 3 to 3600 my page was scoring much better: http://www.webpagetest.org/result/131030_2F_1CPT/1/pagespeed/

    An this is after change: http://www.webpagetest.org/result/131031_3X_FJW/

    Any idea what is wrong now please?

  15. futtta
    Member
    Plugin Author

    Posted 5 months ago #

    just had a look, your site seems broken. can you empty wp super cache cache?

  16. jronder
    Member
    Posted 5 months ago #

    Sorry even when I make test on google page speed I get error on back end and the site is down!Instead the opening the site it will say me download.gz!

  17. futtta
    Member
    Plugin Author

    Posted 5 months ago #

    indeed; empty the wp super cache cache and see if that helps.

  18. jronder
    Member
    Posted 5 months ago #

    Thank you Futta, it helped, I almost got a heart attack:-( I still have even worst result as before:-( but perhaps it is becouse I did not set it properly.

    Is there some guide for beginners I can follow to set wp super chache please?

    Thank you,
    July

  19. futtta
    Member
    Plugin Author

    Posted 5 months ago #

    well, your result is quasi identical now to the one you had yesterday;
    yesterday; http://www.webpagetest.org/result/131030_2F_1CPT/
    today (just now); http://www.webpagetest.org/result/131031_0F_GNG/

    next step would be to activate/ configure autoptimize (it isn't now)?

    (meaning that, given the results, you can consider WP Super Cache configured sufficiently to get your site to the next level with Autoptimize)

  20. jronder
    Member
    Posted 5 months ago #

    Thank you very much Futta, now I see the result.
    What do you mean activate/configure autoptimize? where can I do it?

    Thank you so much for your time Futta!

  21. futtta
    Member
    Plugin Author

    Posted 5 months ago #

    Well, as we're in the Autoptimize support forum here, I supposed you had installed that plugin (for which I am the maintainer).

    WP Super Cache acts on HTML and keeps entire pages in cache, but does not optimize JavaScript and CSS. That's where Autoptimize comes in; it aggregates, minifies and caches CSS and JS (and minifies the HTML as well). WP Super Cache + Autoptimize combined can yield pagespeed-scores of over 90.

    You can read more on how to configure it in the FAQ here.

  22. jronder
    Member
    Posted 5 months ago #

    Thank you Futta, I have not seen that plugin before. Thank you very much,I have just installed it. But there is so many questions and things to fill out. Where can I see some guide to do it please?

    I promise to leave you alone than:-)
    Thank you
    July

  23. futtta
    Member
    Plugin Author

    Posted 5 months ago #

    well, the FAQ should help, no?

    ...
    (leaving you some time to read the faq)
    ...

    ...

    if not;

    1. check the "Optimize HTML Code?" and "Optimize CSS Code?" checkboxes (based on your site's source code, these will probably work out of the fox)
    2. save and check your site
    3. if not OK, disable "optimize CSS Code", click on "Save & empty cache" and try again
    4. for javascript, as you're running a theme that uses jQuery (the horror), you'll have to do some trial and error;
      • I would first try with "Optimize JavaScript Code?" + (in the advanced settings) "Force JavaScript in head".
      • If that breaks stuff check the option "look only for scripts in head" (and again "save & empty cache", off course).
      • If this continues to break things, you could try with "jquery.js" in the list of scripts to exclude.
      • If you still can't get everything to function correctly, you could disable JS-optimization alltogether (you'll have at least your HTML & more importantly your CSS optimized).
  24. jronder
    Member
    Posted 5 months ago #

    Thank you so much Futta!You are realy amazing!

    1. check the "Optimize HTML Code?" and "Optimize CSS Code?" checkboxes (based on your site's source code, these will probably work out of the fox)
    -This worked for me and did not break anything,

    2.I would first try with "Optimize JavaScript Code?" + (in the advanced settings) "Force JavaScript in head".
    -I also did this and nothing broke.

    On the end I have checked on the google page speed, but the score is the same with this report:-( Did I do something wrong?

    Your page has 5 blocking script resources and 2 blocking CSS resources. This causes a delay in rendering your page.

    None of the above-the-fold content on your page could be rendered without waiting for the following resources to load. Try to defer or asynchronously load blocking resources, or inline the critical portions of those resources directly in the HTML.
    Remove render-blocking JavaScript:
    http://maps.google.com/maps/api/js?sensor=false&ver=3.0
    http://maps.gstatic.com/intl/en_us/mapfiles/api-3/14/11/main.js
    http://s0.wp.com/wp-content/js/devicepx-jetpack.js?ver=201344
    http://s.gravatar.com/js/gprofiles.js?ver=2013Octaa
    http://stats.wordpress.com/e-201344.js
    Optimize CSS Delivery of the following:
    http://villasdiani.com/wp-content/cache/autoptimize/autoptimize_498bfb2de4d47c00d3dca0a6b99f6a58.php
    http://villasdiani.com/wp-content/cache/autoptimize/autoptimize_1ce815464f0cb9325573df64bee34583.php

  25. futtta
    Member
    Plugin Author

    Posted 5 months ago #

    Well, if you compare yesterday's result with the most recent test I ran, the improvement is substantial; download size went from 1,280 KB to 1,088 KB, pagespeed from 86 to 92 and (most importantly) load time from 6.224s to 3.406s.

    The blocking JS is external JavaScript, Autoptimize doesn't touch that. The blocking CSS is another issue (and a newer one, as the guideline up until recently was to put all CSS in the head, which is now consired blocking), which you can read about here and here (spoiler; don't bother with that yet, unless you're really deep into mobile).

  26. jronder
    Member
    Posted 5 months ago #

    Thank you very much Futta!You are realy great!

    Thank you!
    All the best
    July

  27. jronder
    Member
    Posted 5 months ago #

    Halloo Futta, Unfortunately I am back,

    I have viewed my page sources and guess there is something realy screwed up:-(

  28. jronder
    Member
    Posted 5 months ago #

    I was trying to paste here the page source using the code tab, but I guess it does not allow me.

  29. futtta
    Member
    Plugin Author

    Posted 5 months ago #

    yeah, pasting code can be a pain. but what is the problem you're observing in the code?

  30. jronder
    Member
    Posted 5 months ago #

    Thank you very much Futta for your reply. It looks very different and the bottom it says:
    <!-- Page not cached by WP Super Cache. Check your settings page. Not caching requests by known users. (See Advanced Settings page)

Reply »

You must log in to post.

About this Plugin

About this Topic