Forum Moderators: not2easy

Message Too Old, No Replies

cache control

Google speed test wants cache control

         

night707

7:32 pm on Sep 30, 2016 (gmt 0)

10+ Year Member Top Contributors Of The Month



Google speed test demands some "Leverage browser caching
Setting an expiry date or a maximum age in the HTTP headers for static resources instructs the browser to load previously downloaded resources from local disk rather than over the network.

and such .htaccess entries don't seem to please them ...

Does anyone have an idea how to make it work ?

<IfModule mod_expires.c>
ExpiresActive On
<FilesMatch "\.(|ico|js|gif|jpg|jpeg|png|swf)$">
ExpiresDefault A29030400
</FilesMatch>
</IfModule>

or

ExpiresActive On
ExpiresDefault “access plus 1 week”
ExpiresByType text/css M604800

not2easy

9:02 pm on Sep 30, 2016 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



There have been a few discussions in the Apache Forum about this topic, but because it depends on the server setup, the configuration of the server I believe it is best to consult with the host for a definitive answer. If you like, you can try and test some of the suggested methods. Remember that the "ExpiresActive ON" and "Expires Default" set the basics and additional controls for files that change more frequently or files you do not want cached are what you should work on.

The formats are explained at the Apache site: [httpd.apache.org...] and you can see a few past discussions in the Apache Forums here: [webmasterworld.com...] and also here: [webmasterworld.com...] that may help. Because the "best" way to do this depends on the type of files, whether they are static or dynamically generated and on the server's settings, there are a lot of variables. Best practice is to read and try, by using tools to check the headers, clearing your cache and testing.

Setting Expires headers for dynamically generated files (such as Drupal or WordPress generates) is best done internally - within the CMS rather than in .htaccess because the "files" don't exist until they are requested.

night707

8:55 am on Oct 1, 2016 (gmt 0)

10+ Year Member Top Contributors Of The Month



many thanks for the links not2easy

keyplyr

9:52 am on Oct 1, 2016 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Just. FYI - even if you do install correct caching and it is working as intended, Page Speed may not recognize it and may return the same "Leverage browser caching" warning so it's best to validate at another tool (or more.)

Also, if using HTTPS, Page Speed results may also report caching warning depending on the header your server returns.

night707

7:32 am on Oct 2, 2016 (gmt 0)

10+ Year Member Top Contributors Of The Month



Indeed, other page tests confirm valid browser caching andi have tried various methods, but none does not please page speed ... so i am still searching for a functioning entry.

Perhaps someone may have a functioning htaccess entry?

keyplyr

8:05 am on Oct 2, 2016 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Don't worry about it. Not passing all the rules at Page Speed means nothing in terms of your page ranking. The tool is buggy.