Closed brunofacca closed 7 years ago
idk what exactly the issue is ... I'd recommend a bundle open rack-cache
and then puts
ing inside the middleware or file cache to see what exactly is going on
Thanks for your guidance.
I have done as you suggested and found that I could not see any files being stored in /var/cache/rack
because they were being stored in Rails.root/tmp/cache
.
By setting config.action_dispatch.rack_cache
to true
, Rails automatically adds Rack::Cache
to the middleware stack with the following options: {:metastore=>"rails:/", :entitystore=>"rails:/", :verbose=>false}
. See the Rails source code here and here.
So the following code in config/application.rb
was adding Rack::Cache
to the middleware stack twice and the options I have provided were overridden by Rails' default options.
config.middleware.use Rack::Cache,
verbose: true,
metastore: 'file:/var/cache/rack/meta',
entitystore: 'file:/var/cache/rack/body'
# Unintentionally add Rack::Cache to the middleware for the second time
config.action_dispatch.rack_cache = true
hopefully prevented with https://github.com/rtomayko/rack-cache/pull/143
First let me thank you for this great gem.
Before using rack-cache on production servers, I'm attempting to familiarize myself with it in the development environment.
I have included the following in
config/application.rb
After restarting the Rails development server and performing multiple requests, both
/var/cache/rack
subdirectories are still empty and all requests displaymiss, store
in the log and in theX-Rack-Cache header
.I have also attempted to use the heap store and, again, it appears that nothing is being cached (all requests result in
miss, store
).Could you please advise on how to make Rack::Cache actually cache (store) the files in development mode?
Thanks in advance.