I am tyring to implement browser caching and follow Google PageSpeed's recommendation about setting Last-Modified to some data that's "sufficiently far enough previously." I've the next during my .htaccess:
<IfModule mod_headers.c> <FilesMatch "\.(json|pdf|swf|bmp|gif|jpeg|jpg|png|svg|tiff|ico|flv|js)$"> Header Set Last-Modified "Fri, 01 Jan 2010 12:00:00 GMT" </FilesMatch> </IfModule>
I've mod_headers placed on my server.
Regrettably, Google PageSpeed still gripes and alerts me:
Leverage browser caching The following cacheable resources have a short freshness lifetime. Specify an expiration at least one week in the future for the following resources:
After which lists PNGs, GIFs, JPGs, etc. Yahoo YSlow states essentially exactly the same factor.
Searching in the response headers of 1 of my assets that needs to be caching, I check this out:
Date: Tue, 19 Oct 2010 20:12:04 GMT Server: Apache/2.2.14 (Ubuntu) Last-Modified: Tue, 07 Sep 2010 23:51:33 GMT Etag: "2e0e34-2a43-48fb413a96a20" Accept-Ranges: bytes Content-Length: 10819 Content-Type: image/png
As you can tell, the final-Modified data doesn't match things i specified by .htaccess.
Any ideas things i am doing wrong?
Have you thought about simply using unset Last-Modified?
<IfModule mod_headers.c> <FilesMatch "\.(json|pdf|swf|bmp|gif|jpeg|jpg|png|svg|tiff|ico|flv|js)$"> Header unset Last-Modified </FilesMatch> </IfModule>
The FilesMatch section looks fine, therefore it is most likely some tricky bit with Header Set. Hell, could even be situation sensitive. Try
Header set rather than
If the is not what you would like, then tell me and I'll consider it a little more. Unset should work though,