Leveraging browser caching

Here’s how to cache CSS / PNG files.

1. Use Expires caching headers 

i.e. rather than Cache-Control – see:


2. If you’re using Apache these are set in the httpd.conf file:


<IfModule mod_expires.c>

    ExpiresActive On

    ExpiresDefault “access plus 10 days”

    ExpiresByType text/css “access plus 1 week”

    ExpiresByType text/plain “access plus 1 month”

    ExpiresByType image/gif “access plus 1 month”

    ExpiresByType image/png “access plus 1 month”

    ExpiresByType image/jpeg “access plus 1 month”

    ExpiresByType application/x-javascript “access plus 1 month”

    ExpiresByType application/javascript “access plus 1 week”

    ExpiresByType application/x-icon “access plus 1 year”



3. If you’re on a Dreamhost VPS the httpd.conf file is here:


To access it use:

su – <your-admin-user>

and restart with:

sudo /etc/init.d/httpd2 restart

4. And you can test how successful your updates were here:


Leave a Reply

Your email address will not be published. Required fields are marked *