簡體   English   中英

如何強制 Cache-Control 在 rails 3.2.20 中不存儲

[英]how to force Cache-Control to no-store in rails 3.2.20

有幾個這樣的問題:

但無論我做什么,我覆蓋什么我仍然得到 header (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 的東西

我創建了自己的中間件,它覆蓋了header['Cache-Control']

沒有任何作用

在 Rails 3.2 中,gem no_cache_control僅在 Rails 應用程序以生產模式啟動時才有效。 可以通過在生產模式下啟動您的應用程序來測試它:

rails s -e production

注意:確保你的database.yml指向對生產環境有效的地方。

Rails 7現在有一個no_store 方法

before_action :no_store

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM