How to reset Heroku Rails4 asset pipeline cache

2019-01-17 13:13发布

问题:

According to Heroku documentation:

Heroku now caches 50mb worth of tmp/cache/assets which is a cache directory for the asset pipeline to store intermediate files. This means that future asset compilations will be faster due to not having to recalculate these files.

My question is how do I manually reset or delete this cache so that all of my assets have to be precompiled again? I tried heroku run console and Rails.cache.clear but it did not work. The reason I want to reset the cache is I have changed the config.action_controller.asset_host in my production.rb file but Heroku is not picking up on the change because of the cache.

回答1:

Hopefully this helps. To get changes to Heroku in development I run rake assets:clean and then rake assets:precompile RAILS_ENV=production --trace before committing and pushing to Heroku



回答2:

To purge Heroku's asset cache, you need the Heroku Repo plugin to the Heroku toolbelt. Install that, then use the command

heroku repo:purge_cache

Deploy after purging the cache.



回答3:

For cleaning assets, run:

rake assets:clobber



回答4:

I had this problem, then i realized I forgot to configure to serve static assets on the production env, inside config/enviroments/production.rb

config. serve_static_files = true