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. |
Class Public methods
new(cache_control_header) Link
# 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
Instance Public methods
max_stale?() Link
Returns true if max-stale directive is present (with or without a value)
max_stale_unlimited?() Link
Returns true if max-stale directive is present without a value (unlimited staleness)
no_cache?() Link
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.
no_store?() Link
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.
no_transform?() Link
Returns true if the no-transform directive is present. This directive indicates that a cache or proxy must not transform the payload.
only_if_cached?() Link
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.