Class: Protocol::HTTP::Header::CacheControl
- Defined in:
- lib/protocol/http/header/cache_control.rb
Overview
Represents the cache-control header, which is a list of cache directives.
Constant Summary collapse
- PRIVATE =
The
privatedirective indicates that the response is intended for a single user and must not be stored by shared caches. "private"- PUBLIC =
The
publicdirective indicates that the response may be stored by any cache, even if it would normally be considered non-cacheable. "public"- NO_CACHE =
The
no-cachedirective indicates that caches must revalidate the response with the origin server before serving it to clients. "no-cache"- NO_STORE =
The
no-storedirective indicates that caches must not store the response under any circumstances. "no-store"- MAX_AGE =
The
max-agedirective indicates the maximum amount of time, in seconds, that a response is considered fresh. "max-age"- S_MAXAGE =
The
s-maxagedirective is similar tomax-agebut applies only to shared caches. If boths-maxageandmax-ageare present,s-maxagetakes precedence in shared caches. "s-maxage"- STATIC =
The
staticdirective is a custom directive often used to indicate that the resource is immutable or rarely changes, allowing longer caching periods. "static"- DYNAMIC =
The
dynamicdirective is a custom directive used to indicate that the resource is generated dynamically and may change frequently, requiring shorter caching periods. "dynamic"- STREAMING =
The
streamingdirective is a custom directive used to indicate that the resource is intended for progressive or chunked delivery, such as live video streams. "streaming"- MUST_REVALIDATE =
The
must-revalidatedirective indicates that once a response becomes stale, caches must not use it to satisfy subsequent requests without revalidating it with the origin server. "must-revalidate"- PROXY_REVALIDATE =
The
proxy-revalidatedirective is similar tomust-revalidatebut applies only to shared caches. "proxy-revalidate"
Constants inherited from Split
Instance Method Summary collapse
-
#<<(value) ⇒ Object
Adds a directive to the Cache-Control header.
- #dynamic? ⇒ Boolean
-
#initialize(value = nil) ⇒ CacheControl
constructor
Initializes the cache control header with the given value.
- #max_age ⇒ Object
- #must_revalidate? ⇒ Boolean
- #no_cache? ⇒ Boolean
- #no_store? ⇒ Boolean
- #private? ⇒ Boolean
- #proxy_revalidate? ⇒ Boolean
- #public? ⇒ Boolean
- #s_maxage ⇒ Object
- #static? ⇒ Boolean
- #streaming? ⇒ Boolean
Methods inherited from Split
Constructor Details
#initialize(value = nil) ⇒ CacheControl
Initializes the cache control header with the given value. The value is expected to be a comma-separated string of cache directives.
50 51 52 |
# File 'lib/protocol/http/header/cache_control.rb', line 50 def initialize(value = nil) super(value&.downcase) end |
Instance Method Details
#<<(value) ⇒ Object
Adds a directive to the Cache-Control header. The value will be normalized to lowercase before being added.
57 58 59 |
# File 'lib/protocol/http/header/cache_control.rb', line 57 def << value super(value.downcase) end |
#dynamic? ⇒ Boolean
67 68 69 |
# File 'lib/protocol/http/header/cache_control.rb', line 67 def dynamic? self.include?(DYNAMIC) end |
#max_age ⇒ Object
107 108 109 |
# File 'lib/protocol/http/header/cache_control.rb', line 107 def max_age find_integer_value(MAX_AGE) end |
#must_revalidate? ⇒ Boolean
97 98 99 |
# File 'lib/protocol/http/header/cache_control.rb', line 97 def must_revalidate? self.include?(MUST_REVALIDATE) end |
#no_cache? ⇒ Boolean
87 88 89 |
# File 'lib/protocol/http/header/cache_control.rb', line 87 def no_cache? self.include?(NO_CACHE) end |
#no_store? ⇒ Boolean
92 93 94 |
# File 'lib/protocol/http/header/cache_control.rb', line 92 def no_store? self.include?(NO_STORE) end |
#private? ⇒ Boolean
77 78 79 |
# File 'lib/protocol/http/header/cache_control.rb', line 77 def private? self.include?(PRIVATE) end |
#proxy_revalidate? ⇒ Boolean
102 103 104 |
# File 'lib/protocol/http/header/cache_control.rb', line 102 def proxy_revalidate? self.include?(PROXY_REVALIDATE) end |
#public? ⇒ Boolean
82 83 84 |
# File 'lib/protocol/http/header/cache_control.rb', line 82 def public? self.include?(PUBLIC) end |
#s_maxage ⇒ Object
112 113 114 |
# File 'lib/protocol/http/header/cache_control.rb', line 112 def s_maxage find_integer_value(S_MAXAGE) end |
#static? ⇒ Boolean
62 63 64 |
# File 'lib/protocol/http/header/cache_control.rb', line 62 def static? self.include?(STATIC) end |
#streaming? ⇒ Boolean
72 73 74 |
# File 'lib/protocol/http/header/cache_control.rb', line 72 def streaming? self.include?(STREAMING) end |