Stefan Tilkov's Random Stuff

Deep Etags

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 …

Comments