2011-03-29 74 views
0

我正在寻找方法来禁用Browser Cache for Chrome & SafariROR +禁用浏览器缓存适用于Chrome和Safari!

我发现下面的方法,

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

,也为元标记方法。

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

+0

是不是很简单?你会喜欢它有多简单? – corroded 2011-03-29 10:19:06

+0

我需要解决方案,它会是什么? – Rubyist 2011-03-29 10:26:08

+0

上述方法不起作用吗? – corroded 2011-03-29 10:31:02

回答

0

我面临同样的问题,找到了一个很好的解决方案,我就在博客中以

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

要添加“无缓存”中,添加以下行@的application_controller.rb文件

before_filter :set_no_cache 

和功能

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 
相关问题