Image and resource caching with htaccess
Wednesday 23rd March '11
This is as much a bookmark for myself as anything. I just discovered this .htaccess trick to easily set resource caching with apache. It requires mod_headers enabled which comes compiled by default but switched off. Then all you need do is add something like this to your .htaccess file:
<IfModule mod_headers.c> <FilesMatch ".(flv|gif|jpg|jpeg|png|ico|swf)$"> Header set Cache-Control "max-age=2592000" </FilesMatch> </IfModule>
Which will cache images and flash for one month. The link posted above has loads more info.
Post a comment

Dave 30th Mar 2011
Dude, you know that you'll need a caching server (varnish) if you want the server to do some caching - you can get varnish to honor the header files and take the load off Apache.... great for serving up images (most Apache instances are over 10Mb of memory it loads up all the bloated modules even if its just serving up an image)







