Class: HTTP::Cache::Headers
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- HTTP::Cache::Headers
- Defined in:
- lib/http/cache/headers.rb
Overview
Convenience methods around cache control headers.
Instance Method Summary collapse
-
#forces_revalidation? ⇒ Boolean
Does this message force revalidation.
-
#initialize(headers) ⇒ Headers
constructor
A new instance of Headers.
-
#max_age ⇒ Numeric
considered fresh.
-
#must_revalidate? ⇒ Boolean
Does the cache control include 'must-revalidate'.
-
#no_cache? ⇒ Boolean
Does the cache control include 'no-cache'.
-
#no_store? ⇒ Boolean
Does the cache control include 'no-stor'.
-
#private? ⇒ Boolean
Does the cache control include 'private'.
-
#public? ⇒ Boolean
Does the cache control include 'public'.
-
#vary_star? ⇒ Boolean
Is the vary header set to '*'.
Constructor Details
Instance Method Details
#forces_revalidation? ⇒ Boolean
Returns does this message force revalidation.
19 20 21 |
# File 'lib/http/cache/headers.rb', line 19 def forces_revalidation? must_revalidate? || max_age == 0 end |
#max_age ⇒ Numeric
considered fresh.
50 51 52 |
# File 'lib/http/cache/headers.rb', line 50 def max_age explicit_max_age || seconds_til_expires || Float::INFINITY end |
#must_revalidate? ⇒ Boolean
Returns does the cache control include 'must-revalidate'.
24 25 26 |
# File 'lib/http/cache/headers.rb', line 24 def must_revalidate? matches?(/\bmust-revalidate\b/i) end |
#no_cache? ⇒ Boolean
Returns does the cache control include 'no-cache'.
29 30 31 |
# File 'lib/http/cache/headers.rb', line 29 def no_cache? matches?(/\bno-cache\b/i) end |
#no_store? ⇒ Boolean
Returns does the cache control include 'no-stor'.
34 35 36 |
# File 'lib/http/cache/headers.rb', line 34 def no_store? matches?(/\bno-store\b/i) end |
#private? ⇒ Boolean
Returns does the cache control include 'private'.
44 45 46 |
# File 'lib/http/cache/headers.rb', line 44 def private? matches?(/\bprivate\b/i) end |
#public? ⇒ Boolean
Returns does the cache control include 'public'.
39 40 41 |
# File 'lib/http/cache/headers.rb', line 39 def public? matches?(/\bpublic\b/i) end |
#vary_star? ⇒ Boolean
Returns is the vary header set to '*'.
55 56 57 |
# File 'lib/http/cache/headers.rb', line 55 def vary_star? get("Vary").any? { |v| "*" == v.strip } end |