Module: Cache
- Included in:
- Rambo::Controller
- Defined in:
- lib/rambo/controller/cache.rb
Instance Method Summary collapse
Instance Method Details
#fresh?(model, options = {}) ⇒ Boolean
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/rambo/controller/cache.rb', line 2 def fresh?(model, ={}) @@etags ||= {} etag = Digest::SHA1.hexdigest(model.inspect) response.header['ETag'] = "\"#{etag}\"" response.header['Expires'] = (MooTime.now + [:expires_in]).httpdate if [:expires_in] response.header['Cache-Control'] = 'public' if @@etags[request.uri] == etag response.status = 304 response.body = '' return true else @@etags[request.uri] = etag return false end end |