What's the most correct way of stopping my pages from caching?
Google is giving me mixed responses, so I am guessing it is highly browser 开发者_StackOverflowsubjective, but what would you recommend I put in (and also where) to stop pages caching?
It's been a while, but when I used to do a lot of this, the advice was always to:
Set:
Cache-Control: no-cache
Expires: -1
Cache-Control: max-age -1
Here's a good article about the various nuances.
I've used:
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="0">
Response.CacheControl = "no-cache"
Response.AddHeader "Pragma", "no-cache"
Response.Expires = -1
or in ASP.NET, place this in your code behind (page or master page)
Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1))
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Response.Cache.SetNoStore()
精彩评论