WebPagetest Forums
Cache static content = F - Printable Version

+- WebPagetest Forums (https://www.webpagetest.org/forums)
+-- Forum: Web Performance (/forumdisplay.php?fid=3)
+--- Forum: Optimization Discussions (/forumdisplay.php?fid=5)
+--- Thread: Cache static content = F (/showthread.php?tid=11146)



Cache static content = F - Arris - 05-20-2012 04:38 AM

Greetings everyone,

I am hoping to get some clarification on how to resolve failing at "Leverage browser caching of static assets."

I am an Apache setup with my hosting company. I tried so many different setups in my htaccess file which I received from discussions here and elsewhere however I just cannot get my images to show it's caching.

Some of the things I tried are (caching for 2 days)...
---------------
<filesMatch "\.(png|jpg|ico|gif|jpeg)$">
Header set Cache-Control "max-age=172800, public, must-revalidate"
</filesMatch>
--------------------------------------
<FilesMatch "\.(png|jpg|ico|gif|jpeg)$">
Header set Cache-Control "max-age=172800, public, must-revalidate"
Header unset Pragma
Header unset Last-Modified
Header unset ETag
FileETag None
</FilesMatch>
---------------------------------------------
ExpiresActive On
ExpiresDefault A0
<filesMatch "\.(png|jpg|ico|gif|jpeg)$">
Header set Cache-Control "max-age=172800, public, must-revalidate"
</filesMatch>
-------------------------------------------

I just don't know what I am doing wrong or missing. I would GREATLY appreciate any assistance or feedback.

Thanks!


RE: Cache static content = F - pmeenan - 05-21-2012 11:21 PM

Since you seem to have mod_expires, try:

Code:
<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/gif A31536000
    ExpiresByType image/jpg A31536000
    ExpiresByType image/jpeg A31536000
    ExpiresByType image/png A31536000
    ExpiresByType image/bmp A31536000
    ExpiresByType text/css A31536000
    ExpiresByType text/javascript A31536000
    ExpiresByType application/javascript A31536000
    ExpiresByType application/x-javascript A31536000
</IfModule>

I noticed you were putting a must-revalidate in the headers. WebPagetest doesn't actually check for that yet but that effectively defeats browser caching since the browser is forced to do an if-modified-since check.


RE: Cache static content = F - Arris - 05-22-2012 08:03 AM

You are awesome! That worked.

Since I am still making changes to some of the images I didn't want to set the Cache-Control age too far until I am finished editing some of the images. I used A604800 instead of A31536000 so it will only cache for 7 days for now.

I went from Cache static content = F to Cache static content = B.

I believe I would get an A if I set out the cache age longer as you mentioned.

Thanks again!