Heroku with caching
-
19-09-2019 - |
Question
I'm using page caching within my application. Everything works fine locally. But after I push changes to heroku server. Caching expiration won't work. I use sweepers to track and expire cached pages.
Here's config for caching in the production.rb
config.cache_store = :memory_store
#config.cache_store = :file_store, 'tmp/cache/'
I tried both ways nothing work.
Maybe there's some specific configuration which I don't know.
Solution
The :memory_store
won't work with Heroku, and :file_store
will only work in ./tmp
on the current Dyno (Dynos don't know about each other). They're working on supporting Memcached in beta and you can check out the other docs on taking advantage of Varnish: http://docs.heroku.com/http-caching
OTHER TIPS
Heroku converts regular rails page caching (which writes files to disk, no-go on their read-only filesystems) to use cache-control HTTP headers instead. Of course with this you lose the ability to expire the cache. You can only do :expires_in => some.minutes
.
Check out action caching instead.