Class: SocialAvatarProxy::Configuration::HttpCache
- Inherits:
-
Object
- Object
- SocialAvatarProxy::Configuration::HttpCache
- Defined in:
- lib/social_avatar_proxy/configuration/http_cache.rb
Instance Method Summary collapse
- #apply_caching_headers(response) ⇒ Object
- #configure(&block) ⇒ Object
- #disabled? ⇒ Boolean
- #enabled? ⇒ Boolean
Instance Method Details
#apply_caching_headers(response) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# 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) ⇒ Object
4 5 6 7 |
# File 'lib/social_avatar_proxy/configuration/http_cache.rb', line 4 def configure(&block) @enabled = true instance_eval(&block) end |
#disabled? ⇒ Boolean
27 28 29 |
# File 'lib/social_avatar_proxy/configuration/http_cache.rb', line 27 def disabled? !enabled? end |
#enabled? ⇒ Boolean
31 32 33 |
# File 'lib/social_avatar_proxy/configuration/http_cache.rb', line 31 def enabled? !!@enabled end |