Skip to content

Conversation

shuber
Copy link

@shuber shuber commented May 29, 2013

This fixes the issues discussed in rails/cache_digests#48 and allows cache digests to be recalculated when templates are changed in the development environment (or any environment with the cache_template_loading config disabled) without requiring an application restart.

Note that this applies to 4-0-stable and 4-0-0 as well.

ActionView::Base.cache_template_loading is disabled.
@jridgewell
Copy link

This has gotten out of sync with master, but is still needed (#10752 is a dupe with the same problem). @shuber Any chance you can update this?

@pftg
Copy link
Contributor

pftg commented Jun 29, 2013

Will be great to have regression tests for this feature!

@courtsimas
Copy link

@shuber or @jridgewell any update on this?

@jridgewell
Copy link

@courtsimas, I've found it easier to just monkey patch the cache as a blackhole hash:
https://github.com/cloudspace/ettu/blob/master/lib/ettu/railtie.rb#L10-L12
https://github.com/cloudspace/ettu/blob/master/lib/ettu/railtie.rb#L20-L24

Properly fixing this issues would require either creating a ActiveSupport::Cache compliant wrapper for the thead_safe gem, or removing the thread_safe gem and using ActiveSupport::Cache::MemoryStore (which is also thread safe...).

More info here: https://groups.google.com/forum/#!searchin/rubyonrails-core/thread_safe/rubyonrails-core/QgJ9QyEbgAs/4iOB4AUb-5gJ

@thedarkone
Copy link
Contributor

@jridgewell if you are willing to work on this (@shuber seems to be busy right now), you should open a new PR.

The best fix for this is just to add a to_prepare callback instead of mucking with NullStore:

# in actionpack/lib/action_view/railtie.rb
if in_development? && caching_is_enabled?
  ActionDispatch::Reloader.to_prepare { ActionView::Digestor.cache.clear }
end

Don't forget to document it, close all the relevant issues and a test case would also be nice :) ❤️.

@jridgewell
Copy link

@thedarkone @josh-lauer and I originally went with the to_prepare route but realized that it would only be fired when .rb files would be modified and not .erb files (or any other template files).

Instead, we are directly checking for config.action_view.cache_template_loading (ActionView::Resolver.caching is set to the same value) before storing the the digest in the cache. The greatly eased testing, since the caching setting can be changed on the fly and not just at initialization.

@rafaelfranca
Copy link
Member

Closed by #11768

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.

6 participants