clear cache on Ruby on Rails on Ubuntu (nginx + unicorn)

June 30, 2014 8.8k views

I set up a new Ruby on Rails on Ubuntu (nginx + unicorn) droplet. The only thing I did was change the html in the default home page (/home/rails/app/views/home/index.html.erb).

Now when I load and reload the home page at it switches between the original home page and the new one. I have checked with others to see if the behavior is the same for them and it is.

I've tried
rake tmp:cache:clear
rake assets:clean

What other options are there?

1 comment
  • I have this issue as well. I have to restart the server for it to work. :(

3 Answers

I tried the suggestions here:

Does anyone have experience with creating a droplet using this image? I am wondering if the image is broken.

Would it be better to set up a rails server starting with a straight Ubuntu 14.x Linux Distro image?

Are you restarting the unicorn server after changing the file? Run:

service unicorn restart

Also make sure that a copy of the page isn't being cached in /home/rails/public/

I have also had problems with caching running Unicorn with multiple worker processes. If you're using
config.cache_store = :memory_store
in your environments/production.rb that could be the issue. In this case it appears that the memory store is duplicated across the workers. Try switching settings to

config.action_controller.perform_caching = false

and see if the behavior stops. If so, you probably need to use a different caching strategy. See http://guides.rubyonrails.org/cachingwithrails.html#cache-stores

Have another answer? Share your knowledge.