instance method http_cache_forever

Ruby on Rails 8.0.4

Since v5.2.8.1

Available in: v5.2.8.1 v6.0.6 v6.1.7.10 v7.0.10 v7.1.6 v7.2.3 v8.0.4 v8.1.2

Signature

http_cache_forever(public: false)

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, set true to indicate that they can serve the cached response to all users.

Parameters

public key = false
Source
# File actionpack/lib/action_controller/metal/conditional_get.rb, line 321
    def http_cache_forever(public: false)
      expires_in 100.years, public: public, immutable: true

      yield if stale?(etag: request.fullpath,
                      last_modified: Time.new(2011, 1, 1).utc,
                      public: public)
    end

Defined in actionpack/lib/action_controller/metal/conditional_get.rb line 321 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActionController::ConditionalGet

Type at least 2 characters to search.

↑↓ navigate · open · esc close