HTTP ETags

spedometer I tried out YSlow on some of my web sites recently.  It’s pretty well done. Most of the tricks were known to me, but this one trick about ETags (Rule #13) was very interesting to read.  Since ETags are indeed useless on my site, I’ve turned them off.

The basic problem is that many web servers (including Apache & IIS) use server-specific mechanisms to compute ETag values.  This can break if the files are served from a server farm because each server in the farm can present a different ETag value. 

Of course, synchronizing a value may seem easy; but in practice it is not.  One suggestion might be to use a MD5 hash of the content.  That can be made to work; but it isn’t trivial for a server; it either needs a cache of these, or it needs to re-compute.  MD5 is relatively cheap to calculate, but certainly not free.  If-Modified-Since solves the problem and requires no computation at all.

Leave a Reply

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