I’ve written about the Yahoo and Google tools available for helping you find ways to speed up your site. There are lots of good suggestions that are easy to understand, but there’s one that isn’t so well known.
If you are getting an warning about The following resources are missing a cache expiration, here’s what that means, and how to fix it.
You can modify your .htaccess file to make sure that the right type of things get cached on your site.
Here’s what I usually use:
ExpiresActive On #Add Cache-Control Headers Header set Cache-Control "max-age=3153600, public" #Add Cache-Control Headers Header set Cache-Control "max-age=86400, public, must-revalidate" #Add Cache-Control Headers Header set Cache-Control "max-age=3600, must-revalidate"
In the next block, xml and txt live slightly shorter before having to be requested again, and finally html files only live for an hour before needing to be requested.
Putting the code inside of the <IfModule mod_expires.c> tag allows you to trap and test if mod_expires.c is included in your Apache build. If you try to insert the code and mod_expires.c isn’t included, you’ll usually see a 500 error displayed.
Speed of Light photo by John Talbot via Flickr