Skip to content

When your templates change, browser caches bust automatically.#16527

Merged
jeremy merged 1 commit into
rails:masterfrom
jeremy:etag_with_template_digest
Aug 17, 2014
Merged

When your templates change, browser caches bust automatically.#16527
jeremy merged 1 commit into
rails:masterfrom
jeremy:etag_with_template_digest

Conversation

@jeremy

@jeremy jeremy commented Aug 16, 2014

Copy link
Copy Markdown
Member

New default: the template digest is automatically included in your ETags.
When you call fresh_when @post, the digest for posts/show.html.erb
is mixed in so future changes to the HTML will blow HTTP caches for you.
This makes it easy to HTTP-cache many more of your actions.

If you render a different template, you can now pass the :template
option to include its digest instead:

  fresh_when @post, template: 'widgets/show'

Pass template: false to skip the lookup. To turn this off entirely, set:

  config.action_controller.etag_with_template_digest = false

@dhh

dhh commented Aug 16, 2014

Copy link
Copy Markdown
Member

Looks good to me 👍

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for the block arg?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah - included it to make it clear that we aren't using the instance_eval form of on_load. We're being called like a normal block.

@robin850 robin850 added this to the 4.2.0 milestone Aug 17, 2014
New default: the template digest is automatically included in your ETags.
When you call `fresh_when @post`, the digest for `posts/show.html.erb`
is mixed in so future changes to the HTML will blow HTTP caches for you.
This makes it easy to HTTP-cache many more of your actions.

If you render a different template, you can now pass the `:template`
option to include its digest instead:

  fresh_when @post, template: 'widgets/show'

Pass `template: false` to skip the lookup. To turn this off entirely, set:

  config.action_controller.etag_with_template_digest = false
jeremy added a commit that referenced this pull request Aug 17, 2014
When your templates change, browser caches bust automatically.
@jeremy
jeremy merged commit a08ca4a into rails:master Aug 17, 2014
@jeremy
jeremy deleted the etag_with_template_digest branch August 17, 2014 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants