I just installed Google's Page Speed plugin to Firebug, and everything looks good except for caching. I have set headers to cache my JS and CSS files, but it says the images aren't being cached. How can I make sure the images get cached for 30 days? These are static images, so I can't just add the headers with PHP like I did with the other files.
Where would that go?
James Simpson
2010-06-06 16:05:16
+1
A:
The page at http://www.askapache.com/htaccess/apache-speed-cache-control.html suggests something like this:
Add Cache-Control Headers
This goes in your root .htaccess file but if you have access to httpd.conf that is better.
This code uses the FilesMatch directive and the Header directive to add Cache-Control Headers to certain files.
# 480 weeks
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Cache-Control "max-age=290304000, public"
</FilesMatch>
aioobe
2010-06-06 16:06:44
I don't know what is wrong, but this is causing httpd to fail. I added that into httpd.conf and then restarted httpd, but it won't restart unless I remove that from httpd.conf.
James Simpson
2010-06-06 18:03:32
Nothing shows in the error log, and all it said when I tried restarting was "httpd has failed, please contact the sysadmin"
James Simpson
2010-06-06 18:26:30