Ryan Bates' render-caching gem is nice, but it keys cache entries by request_uri
s:
def render_with_cache(key = nil, options = nil)
key ||= request.request_uri # <----
body = Rails.cache.read(key)
if body
render :text => body
else
yield if block_given?
render unless performed?
Rails.cache.write(key, response.body, options)
end
end
This is an incomplete solution since what my application renders for a given URI varies based on:
- The current user
- The format of the request (html, js, atom)
How can I modify this method take the current user and request format into account?