Caching is good for you

I’ve asked [Apache][] to start sending out Cache-Control and Expires headers for PNG and JPEG images. They are set to expire after one week — this means that your browser wont even try to load the images from my server until a week has passed. This should give you a more smooth browsing experience because the browser only fetches the [XHTML][].

The trick is very simple, just add the following to a .htaccess file:

<IfModule mod_expires.c>
    ExpiresActive on
    ExpiresByType image/jpeg "now plus 1 week"
    ExpiresByType image/png "now plus 1 week"

Also, I’ve turned indexes on in the /downloads/ directory — this is also very simple, just make a .htaccess file with

Options +Indexes

Leave a comment