简体   繁体   English

ROR +禁用Chrome和Safari浏览器缓存!

[英]ROR + Disable Browser Cache For Chrome & Safari !

I am looking for method to disable Browser Cache for Chrome & Safari 我正在寻找禁用Browser Cache for Chrome & Safari方法

I found following method, 我发现以下方法,

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

and also for meta tag method. 以及元标记方法。

But i am looking for simple method, to disable browser cache for entire website. 但我正在寻找一种简单的方法,以禁用整个网站的浏览器缓存。

I faced the same problem and found a good solution and I blogged it to 我遇到了同样的问题,找到了一个好的解决方案,然后将其写到

http://www.fordevs.com/2011/10/how-to-prevent-browser-from-caching-a-page-in-rails.html http://www.fordevs.com/2011/10/how-to-prevent-browser-from-caching-a-page-in-rails.html

To add 'no-cache', add the following lines @ the application_controller.rb file 要添加“ no-cache”,请在application_controller.rb文件中添加以下行

before_filter :set_no_cache

and the function 和功能

def set_no_cache
   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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM