【问题标题】:ROR + MVC Disable Browser CacheROR + MVC 禁用浏览器缓存
【发布时间】:2011-07-25 01:19:22
【问题描述】:

我正在寻找禁用整个 Ruby On Rails MVC 网站

的浏览器缓存的方法

我找到了以下方法,

Response.Cache.SetExpires(DateTime.Now.AddSeconds(5));
Response.Cache.SetCacheability(HttpCacheability.Public);
Response.Cache.SetValidUntilExpires(true);

还有元标记方法。

<meta http-equiv="PRAGMA" content="NO-CACHE">

但我正在寻找简单的方法,禁用整个网站的浏览器缓存。

【问题讨论】:

  • 以上问题的答案如下!!!

标签: javascript ruby-on-rails-3 caching web-applications cache-control


【解决方案1】:

朋友们,经过长时间的 Google 搜索。我有一个解决方案。我不知道这是更好还是最好。但是我的问题已经解决了。

在 application_controller.rb 中的代码下方添加..

  before_filter :set_cache_buster

  def set_cache_buster
    response.headers["Cache-Control"] = "no-cache, no-store, max-age=0, must-revalidate"
    response.headers["Pragma"] = "no-cache"
    response.headers["Expires"] = "Fri, 01 Jan 1990 00:00:00 GMT"
  end

谢谢咕咕咕

【讨论】:

    猜你喜欢
    • 2011-07-25
    • 1970-01-01
    • 2012-01-05
    • 2018-08-30
    • 1970-01-01
    • 1970-01-01
    • 2018-06-29
    • 2012-12-13
    • 2010-10-29
    相关资源
    最近更新 更多