instance method
http_cache_forever
Ruby on Rails edge
Since v5.0.7.2Signature
http_cache_forever(public: false, last_modified: nil, &block)
Cache or yield the block. The cache is supposed to never expire.
You can use this method when you have an HTTP response that never changes, and the browser and proxies should cache it indefinitely.
-
public: By default, HTTP responses are private, cached only on the user’s web browser. To allow proxies to cache the response, settrueto indicate that they can serve the cached response to all users. -
last_modified: Default to a fixed date in the past, but can be passed to a more relevant time.
Parameters
-
publickey = false -
last_modifiedkey = nil -
blockblock
Source
# File actionpack/lib/action_controller/metal/conditional_get.rb, line 323
def http_cache_forever(public: false, last_modified: nil, &block)
expires_in 100.years, public: public, immutable: true
yield if stale?(etag: request.fullpath,
last_modified: (last_modified || Time.new(2011, 1, 1)).utc,
public: public)
end
Defined in actionpack/lib/action_controller/metal/conditional_get.rb line 323
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActionController::ConditionalGet