Only clear ActionView caches in dev when files change#35629
Only clear ActionView caches in dev when files change#35629kaspth merged 1 commit intorails:masterfrom
Conversation
0e28448 to
1ba93cc
Compare
kaspth
left a comment
There was a problem hiding this comment.
I'm really excited about this! Thanks for working on it.
There was a problem hiding this comment.
Did you look into swapping app.executor to app.reloader?
|
Lovely! Code wise this is good to go for me. As for the TODOs:
|
PR incoming related to this 😉 EDIT: See #35688 |
bbde52e to
ba0828c
Compare
|
This is ready for review! Benchmarks in my (very view heavy, not doing much else) test app look very promising! BeforeAfter |
|
@jhawthorn since #35688 has been merged, do we still need to talk about no dev mode reloading for |
ba0828c to
126f4cc
Compare
Yep! We've lost reloading on the deprecated behaviour, which I think is fine. I've added a CHANGELOG entry noting custom ActionView::Resolver subclasses (which should be pretty rare) may need to add their own cache clearing. I think this is good to go! |
|
@jhawthorn ❤️ |
|
|
||
| To speed up development mode, view caches are only cleared when files in | ||
| the view paths have changed. Applications which have implemented custom | ||
| ActionView::Resolver subclasses may need to add their own cache clearing. |
There was a problem hiding this comment.
I was wondering if we should expose ActionView::LookupContext::DetailsKey.clear as clear_cache on resolvers. iirc DetailsKey is private so users shouldn't know about that constant directly — and I don't know how else they'd clear the cache. What do you think?
There was a problem hiding this comment.
👍 I agree it needs a better (and not private) name. It's a little tricky because afaict having Resolver#clear_cache wouldn't currently work, when testing I got errors unless we cleared all the caches.
Maybe we should expose ActionView::CacheExpiry.clear_cache (ie. make it class-level and document it)
There was a problem hiding this comment.
Should the resolvers know about ActionView::CacheExpiry? Currently the cache expiry knows about the resolvers, so it seems off that we allow double "binding". Since it's just abstracting a reference to DetailsKey anyway, how about a class-level ActionView::Resolver.clear_caches?
Which we then also use in lieu of clear_cache in CacheExpiry.

Builds on #35623 and #35628
This changes the dev-mode actionview cache expiration, which used to run before each request, to only change if any files in the view directories have changed.
This should make dev mode template rendering the same speed as production! ⚡️ (though I'm sure there will be other dev mode things slowing it down)
Todo
Find out what people use that isn't aMake a changelog entry that those with non-FileSystemResolver resolvers will need to clear caches themselves if they want dev mode reloading.FileSystemResolverrender file:(we can't exactly listen to all changes on/). Decide if that's okay.