【发布时间】:2014-11-18 12:46:33
【问题描述】:
有几个 S.O.像这样的问题:
- Rails ( set_no_cache method) Cannot disable browser caching in Safari and Opera
- How to prevent browser page caching in 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 4.1 的项目上测试了
no_cache_controlgem,它可以工作,但不适用于这个 Rails 3.2.20 项目
标签: ruby-on-rails ruby-on-rails-3 cache-control