123456789_123456789_123456789_123456789_123456789_

Module: ActionController::EtagWithTemplateDigest

Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Included In:
Base, ::ActionView::TestCase::TestController, Rails::ApplicationController, Rails::InfoController, Rails::MailersController, Rails::WelcomeController
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
Defined in: actionpack/lib/action_controller/metal/etag_with_template_digest.rb

Overview

When our views change, they should bubble up into HTTP cache freshness and bust browser caches. So the template digest for the current action is automatically included in the ETag.

Enabled by default for apps that use Action View. Disable by setting

config.action_controller.etag_with_template_digest = false

Override the template to digest by passing :template to fresh_when and stale? calls. For example:

# We're going to render widgets/show, not posts/show
fresh_when @post, template: 'widgets/show'

# We're not going to render a template, so omit it from the ETag.
fresh_when @post, template: false

ConditionalGet - Attributes & Methods

Class Method Summary

Instance Attribute Summary

Instance Method Summary

ConditionalGet - Included

#expires_in

Sets a HTTP 1.1 Cache-Control header.

#expires_now

Sets a HTTP 1.1 Cache-Control header of no-cache so no caching should occur by the browser or intermediate caches (like caching proxy servers).

#fresh_when

Sets the etag, last_modified, or both on the response and renders a 304 Not Modified response if the request is already fresh.

#stale?

Sets the etag and/or last_modified on the response and checks it against the client request.

Head - Included

#head

Returns a response that has no content (merely headers).

RackDelegation - Included

DSL Calls

included

[ GitHub ]


24
25
26
27
28
29
30
31
32
33
# File 'actionpack/lib/action_controller/metal/etag_with_template_digest.rb', line 24

included do
  class_attribute :etag_with_template_digest
  self.etag_with_template_digest = true

  ActiveSupport.on_load :action_view, yield: true do |action_view_base|
    etag do |options|
      determine_template_etag(options) if etag_with_template_digest
    end
  end
end

Class Attribute Details

.etaggers (rw)

[ GitHub ]

  
# File 'actionpack/lib/action_controller/metal/conditional_get.rb', line 11

class_attribute :etaggers

.etaggers?Boolean (rw)

[ GitHub ]

  
# File 'actionpack/lib/action_controller/metal/conditional_get.rb', line 11

class_attribute :etaggers

Instance Attribute Details

#etaggers (rw)

[ GitHub ]

  
# File 'actionpack/lib/action_controller/metal/conditional_get.rb', line 11

class_attribute :etaggers

#etaggers?Boolean (rw)

[ GitHub ]

  
# File 'actionpack/lib/action_controller/metal/conditional_get.rb', line 11

class_attribute :etaggers