Browser caching in 60 seconds

There are a multitude of articles out there on browser caching. If you're using Apache as your web server and want to cut to the chase – implement browser caching on your static content (images, css, javascript) by dropping the code below into your httpd.conf or VirtualHost stanza:

ExpiresActive On
ExpiresByType image/gif A2592000
ExpiresByType image/png A2592000
ExpiresByType image/jpg A2592000
ExpiresByType image/jpeg A2592000
ExpiresByType text/css A2592000
ExpiresByType application/javascript A2592000
ExpiresByType application/x-javascript A2592000

This will instruct browsers to cache gif, png, jpeg, css and JavaScript content for 30 days.

If you want to understand more, check out the following articles:

Leverage Browser Caching

Caching Tutorial

Why follow me on Twitter?

  • I tweet about new technologies, services or libraries I find interesting
  • Yeah, sometimes I'll post a pet-peeve or rant about something trivial
  • If I discover something that made my web development life easier, I share it
  • I'll shout out any handy tip that I think might be useful to other devs

Tagged , , , .

Updated: 2011-06-20

Phil LaNasa follow us in feedly