This is a single archived entry from Stefan Tilkov’s blog. For more up-to-date content, check out my author page at INNOQ, which has more information about me and also contains a list of published talks, podcasts, and articles. Or you can check out the full archive.

Deep Etags

Stefan Tilkov,

Joe Gregorio writes about “Deep ETags”, i.e. creating an etag value (which is (one of the factors) used to control HTTP caching) as “low” as possible. I’ve wondered about this a few days ago, and checked the Rails sources — Etag support has been added just recently:

Added that rendering will automatically insert the etag header on 200 OK responses. The etag is calculated using MD5 of the response body. If a request comes in that has a matching etag, the response will be changed to a 304 Not Modified and the response body will be set to an empty string.

So Rails does etags, which is good, but I believe it could offer much better support if this was connected to the lower layers (i.e. ActiveRecord). Should be easy to do …