2011-03-29 71 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 
相關問題