Pragmatism in the real world


I’ve been playing recently with YSlow! from Yahoo! and it’s quite cool. It’s a plug-in for Firefox that works in combination with Firebug that gives you pointers as to why your site isn’t as fast as it could be.

I noticed that one site that I’m developing at the moment was rated C, so thought I’d see what I could do easily to improve it. These are the items that I sorted out.

Configure ETags

[notes] ETags are related to caching and don’t seem especially useful from the notes, so I turned them off in my .htaccess:

FileETag none

GZip Components

[notes] For Apache 2.x, mod_deflate can be used to compress the text data that is sent to the browser. I enabled it in my .htaccess using:

<ifmodule deflate_module>
  AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css

Note that the Apache docs have better configuration settings if you need to support older browsers and other edge cases.

Add an Expires Header

[notes] The Expires header tells the browser when to look for a new version of a given file. mod_expires is the Apache module required and the .htaccess settings I’ve used are:

<ifmodule expires_module>
    ExpiresActive On
    ExpiresByType text/css "access plus 1 month"
    ExpiresByType image/jpeg "access plus 1 month"
    ExpiresByType image/gif "access plus 1 month"
    ExpiresByType image/png "access plus 1 month"
    ExpiresByType application/x-shockwave-flash "access plus 1 month"

Note Don’t use the expires statements when developing!


There you have it. Some simple Apache configuration settings to help improve the performance of your website.

As usual, comments, criticisms and suggested improvements very welcome!