How can I clear rails action cache without restarting the server?
I have a script that updates the Postgres database with new data. I'd like to clear all cached pages after the script completes. but I can't seem to get this to take effect without completely restarting the Heroku server
I have tried without success:
Rails.cache.clear => ["/app/tmp/cache/bootsnap-compile-cache", "/app/tmp/cache/bootsnap-load-path-cache"]rails tmp:cache:clearrails assets:clean
config.cache_store is not set explicitly for production, (I've seen mixed information as to what cache is being used by default)
I have ensured that there is no caching in the browser (by disabling caching in dev tools and bypassing the service worker)
I'm using Heroku with ruby 2.5.3, rails 5.2.1.1, and actionpack-action_caching 1.2.0
How do I know it's not being cached at the database layer or with Fragment Caching?
I added logging to the action which only logs the first time a page is accessed after a restart
Update: I removed action caching and instead better optimized the SQL quarries by using eager loading.
Update 2 (writing in retrospect)
I didn't properly understand how Heroku's dyno's work.
Heroku spines up new VM's (dynos) when using heroku run bash, causing any cache clearing not to affect the webserver running on the existing dyno. To ssh into running dynos you'll want to use heroku ps:exec