I've read a lot of posts and articles and questions & answers on the Rails asset pipeline but I still haven't figured out how to turn off caching altogether.
We're using Rails 3.2.11 and in our Lab environment (similar to development) we're having a problem because even though we are not pre-compiling or fingerprinting assets in the asset pipeline they are still being cached in the Rails (Rack?) cache. This is annoying because some of the assets are ERBs that change based on other configuration so the cache gets stale. In order to try to turn off caching we've set this configuration:
config.action_controller.perform_caching = false
config.assets.compress = false
config.assets.debug = true
# just in case
config.cache_store = :file_store, "file_cache"
However, assets are showing up in tmp/cache/assets
anyway. I would at least expect them to show up in file_cache
, but I really expect them not to be cached at all.
How can we prevent these assets from being cached? Simply deleting the cache is not sufficient in this environment.
Bonus question: as long as these files are being cached, why are they in tmp/
and not in file_cache/
?
To turn off the asset cache:
config.assets.cache_store = :null_store
Note that that is config.assets.cache_store not the Rails config.cache_store.
Also note that Sass has a separate cache for compiled stylesheets, by default in tmp/cache/sass
, and if you want to disable that you have to do that separately:
config.sass.cache = false
To answer the bonus question, when the Rails Guide says:
The default Rails cache store will be used by Sprockets to cache assets in development and production.
I thought they meant the configured Rails cache store would be used. I was wrong, it uses the default cache unless you explicitly change the asset cache.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With