class Goliath::Rack::Cache
Public Instance Methods
post_process(env, status, headers, body)
click to toggle source
# File lib/grass/goliath/rack/cache.rb, line 11 def post_process(env, status, headers, body) if body.is_a?(String) && (Grass.env == "production" || env.config['enable_cache_for_development']) # Generate ETag for body etag = etag_for(body) # Add ETag header headers['ETag'] = etag # Response with status 304 without body if env['HTTP_IF_NONE_MATCH'] == etag status = 304 body = nil end end [status,headers,body] end
Private Instance Methods
etag_for(content)
click to toggle source
Generates ETag for given string
# File lib/grass/goliath/rack/cache.rb, line 31 def etag_for content Digest::MD5.hexdigest(content) end