class SocialAvatarProxy::Configuration::HttpCache
Public Instance Methods
apply_caching_headers(response)
click to toggle source
# File lib/social_avatar_proxy/configuration/http_cache.rb, line 9 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
configure(&block)
click to toggle source
# File lib/social_avatar_proxy/configuration/http_cache.rb, line 4 def configure(&block) @enabled = true instance_eval(&block) end
disabled?()
click to toggle source
# File lib/social_avatar_proxy/configuration/http_cache.rb, line 27 def disabled? !enabled? end
enabled?()
click to toggle source
# File lib/social_avatar_proxy/configuration/http_cache.rb, line 31 def enabled? !!@enabled end
Private Instance Methods
cache_control(value = nil)
click to toggle source
# File lib/social_avatar_proxy/configuration/http_cache.rb, line 36 def cache_control(value = nil) if value @cache_control = value end @cache_control end
disable()
click to toggle source
# File lib/social_avatar_proxy/configuration/http_cache.rb, line 50 def disable @enabled = false end
expires(value = nil)
click to toggle source
# File lib/social_avatar_proxy/configuration/http_cache.rb, line 43 def expires(value = nil) if value @expires = value end @expires end