instance method must_understand

Ruby on Rails 8.1.2

Since v8.1.2

Signature

must_understand()

Adds the must-understand directive to the Cache-Control header, which indicates that a cache MUST understand the semantics of the response status code that has been received, or discard the response.

This is particularly useful when returning responses with new or uncommon status codes that might not be properly interpreted by older caches.

Example

def show
  @article = Article.find(params[:id])

  if @article.early_access?
    must_understand
    render status: 203 # Non-Authoritative Information
  else
    fresh_when @article
  end
end
Source
# File actionpack/lib/action_controller/metal/conditional_get.rb, line 355
    def must_understand
      response.cache_control[:must_understand] = true
      response.cache_control[:no_store] = true
    end

Defined in actionpack/lib/action_controller/metal/conditional_get.rb line 355 · 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