[英]ROR + MVC Disable Browser Cache
I am looking for method to disable Browser Cache for entire Ruby On Rails MVC Website 我正在寻找一种方法来禁用整个Ruby On Rails MVC网站的浏览器缓存
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. 以及元标记方法。
<meta http-equiv="PRAGMA" content="NO-CACHE">
But i am looking for simple method, to disable browser cache for entire website. 但我正在寻找一种简单的方法,以禁用整个网站的浏览器缓存。
Friends, After a long search on Google. 朋友们,在Google上进行了长时间的搜索。 I got one solution for this. 我对此有一个解决方案。 I do not know Is this better or best. 我不知道这是更好还是最好。 But My problem is resolved. 但是我的问题解决了。
Add below your code in application_controller.rb.. 在您的代码下面添加到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
Thanks Goooooogle 谢谢Goooooogle
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.