Sha256: da65790d63fb4710d5ba2b94a2d30bb41ba227213a228877ae72d228195e916e
Contents?: true
Size: 1.26 KB
Versions: 2
Compression:
Stored size: 1.26 KB
Contents
module SocialAvatarProxy class Configuration class HttpCache def configure(&block) @enabled = true instance_eval(&block) end def apply_caching_headers(response) # if we want to expire in a set time, calculate the header if expires response["Expires"] = (Time.now + expires.to_i).httpdate end # if we want to set cache control settings if cc = cache_control directives = [] directives << "no-cache" if cc[:no_cache] directives << "max-stale=#{cc[:max_stale]}" if cc[:max_stale] directives << "max-age=#{cc[:max_age]}" if cc[:max_age] directives << (cc[:public] ? "public" : "private") response["Cache-Control"] = directives.join(", ") end # return the response response end def disabled? !enabled? end def enabled? !!@enabled end private def cache_control(value = nil) if value @cache_control = value end @cache_control end def expires(value = nil) if value @expires = value end @expires end def disable @enabled = false end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
social-avatar-proxy-2.0.1 | lib/social_avatar_proxy/configuration/http_cache.rb |
social-avatar-proxy-2.0.0 | lib/social_avatar_proxy/configuration/http_cache.rb |