如何强制Cache-Control在rails 3.2.20中禁止存储
关于此,有几个SO问题:
- Rails(set_no_cache方法)无法在Safari和Opera中禁用浏览器缓存
- 如何防止Rails中的浏览器页面缓存
但无论我做什么,我覆盖什么,我仍然得到标题(FireFox,Chrome, curl -V
,……任何浏览器)
Cache-Control: must-revalidate, private, max-age=0
我试过了
class ApplicationsController < ActionController::Base before_filter :no_store_cache after_filter :no_store_cache def no_store_cache response.headers["Cache-Control"] = "no-cache, no-store, max-age=0, must-revalidate" response.headers["Pragma"] = "no-cache" response.headers["Expires"] = '-1' end end
我试图直接在ActionController::Base
上调用这个回调( https://github.com/equivalent/no_cache_control.git )
我试图挖掘机rack-cache
中间件覆盖试图强制执行标头的东西
我创建了自己的中间件,它覆盖了header['Cache-Control']
。
什么都行不通
使用Rails 3.2,gem no_cache_control
仅在rails应用程序以生产模式启动时才有效。 可以通过以下方式在生产模式下启动应用来测试:
rails s -e production
注意:确保将database.yml指向适用于生产环境的某个位置。