问题
I'm experimenting with caching in my Rails 3.2 app and enabled caching by adding this to my development.rb file:
config.action_controller.perform_caching = true
Caching works as expected, except that when I load any page the console shows tons of these log entries:
Completed 200 OK in 1006ms (Views: 249.2ms)
cache: [GET /assets/jquery_ujs.js?body=1] miss
cache: [GET /assets/chosen.jquery.min.js?body=1] miss
cache: [GET /assets/bootstrap/bootstrap-tooltip.js?body=1] miss
cache: [GET /assets/bootstrap/tabs.js?body=1] miss
cache: [GET /assets/jquery-ui.js?body=1] miss
cache: [GET /assets/jquery.notifications-1.1.js?body=1] miss
cache: [GET /assets/jquery.js?body=1] miss
cache: [GET /assets/jquery.tablesorter.min.js?body=1] miss
cache: [GET /assets/spin.js?body=1] miss
cache: [GET /assets/olark.js?body=1] miss
cache: [GET /assets/simplemodal/basic.js?body=1] miss
cache: [GET /assets/simplemodal/jquery.simplemodal.js?body=1] miss
cache: [GET /assets/vendor_application.js?body=1] miss
cache: [GET /assets/scrollto.jquery.min.js?body=1] miss
cache: [GET /assets/bootstrap.css?body=1] miss
cache: [GET /assets/scroller.jquery.js?body=1] miss
cache: [GET /assets/application.js?body=1] miss
cache: [GET /assets/application.css?body=1] miss
cache: [GET /assets/simplemodal.css?body=1] miss
cache: [GET /assets/connections.js?body=1] miss
Should I be worried about those cache misses? Is there any way to fix that / silence them?
I'm using the asset pipeline and memcached with dalli.
回答1:
Latest version of Dalli (after 2.0.3) might resolve this issue. See: https://github.com/mperham/dalli/issues/207
Mike's commit today added silence! method. You will need to set Rails.cache.silence! on your initializer for this take effect.
You can update your gemfile to fetch the latest Dalli code from Github or wait for next version of Dalli gem to be released.
回答2:
It's a feature from rack-rache, you can disable rack-cache like this:
config.action_dispatch.rack_cache = false
Rails issue: https://github.com/rails/rails/issues/7581
来源:https://stackoverflow.com/questions/9353160/prevent-cache-miss-warnings-with-perform-caching-on