class ActionDispatch::Http::Cache::Request::CacheControlDirectives
Represents the HTTP Cache-Control header for requests, providing methods to access various cache control directives Reference: www.rfc-editor.org/rfc/rfc9111.html#name-request-directives
Attributes
[R] | max_age |
Returns the value of the max-age directive. This directive indicates that the client is willing to accept a response whose age is no greater than the specified number of seconds. |
[R] | max_stale |
Returns the value of the max-stale directive. When max-stale is present with a value, returns that integer value. When max-stale is present without a value, returns true (unlimited staleness). When max-stale is not present, returns nil. |
[R] | min_fresh |
Returns the value of the min-fresh directive. This directive indicates that the client is willing to accept a response whose freshness lifetime is no less than its current age plus the specified time in seconds. |
[R] | stale_if_error |
Returns the value of the stale-if-error directive. This directive indicates that the client is willing to accept a stale response if the check for a fresh one fails with an error for the specified number of seconds. |
Public class methods
Source code GitHub
# File actionpack/lib/action_dispatch/http/cache.rb, line 75
def initialize(cache_control_header)
@only_if_cached = false
@no_cache = false
@no_store = false
@no_transform = false
@max_age = nil
@max_stale = nil
@min_fresh = nil
@stale_if_error = false
parse_directives(cache_control_header)
end
Public instance methods
Returns true if max-stale directive is present (with or without a value)
Source code GitHub
# File actionpack/lib/action_dispatch/http/cache.rb, line 127
def max_stale?
!@max_stale.nil?
end
Returns true if max-stale directive is present without a value (unlimited staleness)
Source code GitHub
# File actionpack/lib/action_dispatch/http/cache.rb, line 132
def max_stale_unlimited?
@max_stale == true
end
Returns true if the no-cache directive is present. This directive indicates that a cache must not use the response to satisfy subsequent requests without successful validation on the origin server.
Source code GitHub
# File actionpack/lib/action_dispatch/http/cache.rb, line 98
def no_cache?
@no_cache
end
Returns true if the no-store directive is present. This directive indicates that a cache must not store any part of the request or response.
Source code GitHub
# File actionpack/lib/action_dispatch/http/cache.rb, line 105
def no_store?
@no_store
end
Returns true if the no-transform directive is present. This directive indicates that a cache or proxy must not transform the payload.
Source code GitHub
# File actionpack/lib/action_dispatch/http/cache.rb, line 111
def no_transform?
@no_transform
end
Returns true if the only-if-cached directive is present. This directive indicates that the client only wishes to obtain a stored response. If a valid stored response is not available, the server should respond with a 504 (Gateway Timeout) status.
Source code GitHub
# File actionpack/lib/action_dispatch/http/cache.rb, line 91
def only_if_cached?
@only_if_cached
end