1

我正在寻找方法来禁用浏览器缓存,整个Ruby on Rails的MVC网站ROR + MVC禁用浏览器缓存

我发现下面的方法,

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

,也为元标记方法。

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

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

+0

答案对于以上问题如下! – Rubyist 2011-03-29 07:30:09

回答

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 

感谢Goooooogle