YSlow and front end performance improvements..

Only came across YSlow recently, it’s a neat little Firefox plugin for analysing website performance developed by Yahoo!. It provides help/advice for each ‘performance grade’ and the accompanying background articles make a very interesting read.

Obviously not all the advice applies to every site (we’re all not Yahoo) and perhaps some of the advice is of more benefit to huge sites (like having a CDN, again, we’re all not Yahoo). For me, the top three are:
1) Add an Expires Header
2) Configure Etags
3) GZip

However, with regards to Expires and Etags, you really need to know what your doing or it can be a disaster! IMO you shouldn’t really use Expires unless your using versioned content (e.g. instead of serving up http://…file.css serve http://…file-1.0.css) and can set the Expires date in the far far future (to never expire effectively). Then when your content changes on the server side, you change your version and a completely fresh copy is loaded into the cache, to expire again in the far far future). Non-trivial to implement. Setting Expires to be hours/days in the future is just guess work and should be avoided.

You also shouldn’t use ETags at the webserver level unless your sure its safe (as it relies on file based checksums which causes problems on server farms). To effectively use ETags, the value of the ETag in the request header needs to mean something to you when your processing it on the server, e.g. a ‘last modified’ timestamp from the database or something. If your sure the content hasn’t changed, return a 304 response, otherwise return 200 and the full content.

So thread carefully with Expires and ETags, but when they work, they do work very very well! GZip is a no-brainer, its safe, tried and trusted but still needs to be explicitly turned on in the majority of cases. Kudos to Yahoo though, YSlow is an excellent tool, just make sure you fully understand the advice being offered!

Leave a Reply