Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from Aug 17, 2014

Conversation

@jeremy
Copy link
Member

@jeremy jeremy commented Aug 16, 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
@dhh
Copy link
Member

@dhh dhh commented Aug 16, 2014

Looks good to me 👍

Loading

class_attribute :etag_with_template_digest
self.etag_with_template_digest = true

ActiveSupport.on_load :action_view, yield: true do |action_view_base|

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?

Loading

Copy link
Member Author

@jeremy jeremy Aug 17, 2014

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.

Loading

@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 issue Aug 17, 2014
When your templates change, browser caches bust automatically.
@jeremy jeremy merged commit a08ca4a into rails:master Aug 17, 2014
1 check was pending
Loading
@jeremy jeremy deleted the etag_with_template_digest branch Aug 17, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants