-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Use digest cache in development. #20384
Conversation
Ya, it's kinda late here and I think I missed that we should wrap around I should add a test for the caching writing and reading. Possibly even one for the reduced log output. For glory and all the XP! |
I haven't actually dug into this part of the code in a long time. @rafaelfranca could you vet this? |
c |
@@ -42,6 +42,16 @@ class Railtie < Rails::Railtie # :nodoc: | |||
end | |||
end | |||
|
|||
initializer "action_view.fragment_name_cache" do |app| | |||
ActiveSupport.on_load(:action_view) do | |||
if Rails.env.development? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should check consider_all_requests_local
.
Hey @kaspth had any chance to consider this further? |
Sorry, I've totally sweat this out. I'll take a look this weekend 👍 Kasper On 26. jun. 2015 15.29 +0200, David Heinemeier Hanssonnotifications@github.com, wrote:
|
Rocking. Thanks man! On Fri, Jun 26, 2015 at 3:45 PM, Kasper Timm Hansen <
|
186dde3
to
9407b23
Compare
@@ -98,7 +98,7 @@ module CacheHelper | |||
# <%# Template Dependency: todolists/todolist %> | |||
# <%= render_sortable_todolists @project.todolists %> | |||
# | |||
# The pattern used to match these is <tt>/# Template Dependency: (\S+)/</tt>, | |||
# The pattern used to match these is /# Template Dependency: ([^ ]+)/, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unintended change from a rebase, I'll fix it on the next push.
07de57b
to
810013d
Compare
get '/customers/1' | ||
end | ||
|
||
assert write_not_called |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since it is per request should not this be false since other request was made and the cache was cleaned?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haha, doh. Thanks 😄
810013d
to
1f626fd
Compare
@rafaelfranca I'm really stumped on getting these tests to work 😢 It's all coming up black magic, and I have no idea what's going on. For some reason the initializers aren't run. However, if I added this in class ActionView::Base
mattr_accessor(:per_request_fragment_cache) { ActiveSupport::Cache::MemoryStore.new }
end They were run! Do you have any idea why? 😄 The next problem was that |
Weird. I'll debug in my machine |
1f626fd
to
87c56e0
Compare
@dhh I finally got everything up and running here. I reread your original description of the problem and realized I'd been trying to solve the wrong thing 😅 Anyway, the cache now captures generated digests which I think is what you want. Also I looked at |
Hey, hey. Yeah, all I wanted was that the cache we're already using in production for template digests to be used on a per-request basis in development. So the first lookup of a template within a request in development is computed, all subsequent lookups are not. 👍 |
Avoid computing the same fragment digest many times when looping over templates. The cache is cleared on every request so template changes are still picked up.
87c56e0
to
7bd70ba
Compare
@dhh Boom, got it 👍. Way easier once I figured out there was already a cache. I'm closing and reopening for Travis to run. |
Badabing! Awesome. Thanks! |
Fixes #20361
Avoid computing the same fragment digest many times when looping over templates, and
cut down on logging noise.
The cache is cleared on every request, so there's no chance of stale templates being served.
cc @dhh @rafaelfranca @britto