[英]ROR + MVC Disable Browser Cache
我正在寻找一种方法来禁用整个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">
但我正在寻找一种简单的方法,以禁用整个网站的浏览器缓存。
朋友们,在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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.