Optimizing Your Website With Etag and Expire Headers

Share

Optimizing Your Website With Etag and Expire Headers

Earlier this week we noted the release of YSlow, a handy addition to Firebug, the Firefox extension for web developers. YSlow attempts to discern reasons why your webpages are loading slowly.

As a result of that post I received numerous e-mails asking for more information about two of YSlow's suggestions — adding ETags and expire headers to the files you're serving.

I'll confess that I too was bit baffled by both of those tips, in fact I'd never really heard of E-Tags and never bothered to investigate expire headers.

So, for those readers like me, I thought I'd pass along this excellent write-up on both over at Clint Ecker???s blog. While the article is focused on serving up both using the Django web development framework, Ecker includes ways to configure both the Apache webserver and Lighttpd server to do the same.

If you're not using Django on your site, just skip those sections and check out the Apache tips (or Lighttpd if you happen to have it installed).

For Django the E-tags process is simple, just include some middleware in your settings.py file and you're done. For Apache you'll need to use an .htaccess file.

For the expire headers in Apache you'll need to check and confirm that your server is using the “mod_expired” package and then it's just a matter of adding some more lines to the .htaccess file.