问题
I am looking for method to disable Browser Cache for entire Ruby On Rails MVC Website
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.
回答1:
Friends, After a long search on 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..
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
来源:https://stackoverflow.com/questions/5469089/ror-mvc-disable-browser-cache