I applied cache to my heroku rails app and it works well. But everytime I deploy to heroku, I also want to clear cache automatically.
so I googled and I found this
Heroku doesn't currently support a pipeline of actions to occur after deployment. You'll need something like Codeship or TravisCI to create a recipe of steps that happen during deployment
Disclosure: I am a customer of Codeship.
Rails has a built in rake task:
rake tmp:clear
heroku run rake tmp:cache:clear
http://guides.rubyonrails.org/command_line.html#tmp
The following should work on cedar:
heroku run console
..then wait 5 seconds for heroku console to boot
Rails.cache.clear
Then you should see the cache clear, and you can quit console. Remember you might have to refresh a few times because your local machine will often cache assets and such in your browser until it makes a fresh request.
If it happens to be assets that you're caching though, you don't need to go through a manual clear every time you push, you just need to have the asset pipeline set up and make sure all your js/css(less/sass)/static images are being compiled with hashes at the end of their filenames.
You should be able to create a cache clearing rake task that looks something like this:
namespace :cache do
desc "Clears Rails cache"
task :clear => :environment do
Rails.cache.clear
end
end
and invoke it directly in one command that you can use in your post deploy hook - like so:
heroku run rake cache:clear
Ruby on Rails has a magical ENV variable called 'RAILS_CACHE_ID'. I set this to the git commit id whenever I deploy: heroku config:set RAILS_CACHE_ID=$CIRCLE_SHA1