instance method fresh?

Ruby on Rails 8.1.2

Since v3.0.20

Available in: v3.0.20 v3.1.12 v3.2.22.5 v4.0.13 v4.1.16 v4.2.9 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

fresh?(response)

Check response freshness (Last-Modified and ETag) against request If-Modified-Since and If-None-Match conditions. If both headers are supplied, based on configuration, either ETag is preferred over Last-Modified or both are considered equally. You can adjust the preference with config.action_dispatch.strict_freshness. Reference: tools.ietf.org/html/rfc7232#section-6

Parameters

response req
Source
# File actionpack/lib/action_dispatch/http/cache.rb, line 45
        def fresh?(response)
          if Request.strict_freshness
            if if_none_match
              etag_matches?(response.etag)
            elsif if_modified_since
              not_modified?(response.last_modified)
            else
              false
            end
          else
            last_modified = if_modified_since
            etag          = if_none_match

            return false unless last_modified || etag

            success = true
            success &&= not_modified?(response.last_modified) if last_modified
            success &&= etag_matches?(response.etag) if etag
            success
          end
        end

Defined in actionpack/lib/action_dispatch/http/cache.rb line 45 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActionDispatch::Http::Cache::Request

Type at least 2 characters to search.

↑↓ navigate · open · esc close