【问题标题】:how to force Cache-Control to no-store in rails 3.2.20如何强制 Cache-Control 在 rails 3.2.20 中不存储
【发布时间】:2014-11-18 12:46:33
【问题描述】:

有几个 S.O.像这样的问题:

但无论我做什么,我覆盖什么我仍然得到标题(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']

没有任何作用

【问题讨论】:

标签: ruby-on-rails ruby-on-rails-3 cache-control


【解决方案1】:

在 Rails 3.2 中,gem no_cache_control 仅在 rails 应用程序以生产模式启动时才有效。可以通过在生产模式下启动您的应用程序来测试这一点:

rails s -e production

注意:确保您的 database.yml 指向对生产环境有效的位置。

【讨论】:

  • ...哈哈,我会被诅咒的,它有效。好地方,谢谢你
  • 它也适用于我的“暂存”环境(几乎是生产的副本)。所以前提是由于一些开发环境配置它忽略了它
猜你喜欢
  • 2016-08-14
  • 2019-05-17
  • 1970-01-01
  • 2018-08-25
  • 1970-01-01
  • 2016-01-17
  • 1970-01-01
  • 2018-03-23
  • 2015-02-04
相关资源
最近更新 更多