Cache static content = F

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 “.(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

ExpiresActive On
ExpiresDefault A0
<filesMatch “.(png|jpg|ico|gif|jpeg)$”>
Header set Cache-Control “max-age=172800, public, must-revalidate”

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


Since you seem to have mod_expires, try:

<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

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.

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!