ETags with memcached

Posted . Visible to the public.

I love ETags, but there’s something that annoys me: most implementations revolve around pulling a record out of a data store and only “rendering” the response if it hasn’t been modified. 

The problem with this approach is that request has already gone through most of your application stack–parsing params, authentication, authorization, a few database lookups–so ETags are only saving you render time and some bandwidth.

While working on a Sinatra-based JSON web service that gets very heavy traffic, I wanted to find a way to short-circuit requests and avoid most of the stack if a resource hasn’t been modified.

Last edit
Keywords
ruby, caching, makandra
License
Source code in this card is licensed under the MIT License.
Posted by Lexy to makandra dev (2011-01-31 06:59)