views:

210

answers:

1

I'm running Google PageSpeed on my site and it's tell me that I need to
"Specify a cache validator."

The following resources are missing a cache validator. Resources that do not specify a cache validator cannot be refreshed efficiently. Specify a Last-Modified or ETag header to enable cache validation for the following resources:

... then it lists images, CSS, JS, etc.

According to http://code.google.com/speed/page-speed/docs/caching.html#LeverageBrowserCaching:

Set the Last-Modified date to the last time the resource was changed. If the Last-Modified date is sufficiently far enough in the past, chances are the browser won't refetch it.

I have the following in my .htaccess:

<IfModule mod_headers.c>
    <FilesMatch "\.(bmp|css|flv|gif|ico|jpg|jpeg|js|pdf|png|svg|swf|tif|tiff)$">
        Header set Last-Modified "Tue, 31 Aug 2010 00:00:00 GMT"
    </FilesMatch>
</IfModule>

What am I doing wrong?

+2  A: 

I think the problem you are having is with Expire: and not with Last-Modified:. Apache would by default send the file Last-Modified: header based on the file date. I suggest removing the upper code and replacing it with the following:

<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresDefault "access plus 1 year"
</IfModule>

Try with that, if it didn't work try adding this as well:

<IfModule mod_headers.c>
    <FilesMatch "\.(bmp|css|flv|gif|ico|jpg|jpeg|js|pdf|png|svg|swf|tif|tiff)$">
        Header set Last-Modified "Mon, 31 Aug 2009 00:00:00 GMT"
    </FilesMatch>
</IfModule>
aularon
@aularon: I already have things like: ExpiresByType text/css "access plus 1 year" in mod_expires. Any other suggestions?
StackOverflowNewbie
try the new `Header set Last-Modified "Mon, 31 Aug 2009 00:00:00 GMT"` instead of the one you have, this one is a year older!
aularon
Tried it, made no difference. Any other ideas?
StackOverflowNewbie
No, Unfortunately, the only more idea is to inspect google's pagespeed code and check what exactly it's looking for in the response instead of blindly trying, cuz their documentation is generic recommendations with no specific rules.
aularon