解决方法
如果有帮助,您可以尝试使用
HttpResponse.Cache property:
Response.Cache.SetExpires(DateTime.Now.AddSeconds(60)); Response.Cache.SetCacheability(HttpCacheability.Public); Response.Cache.SetValidUntilExpires(false); Response.Cache.VaryByParams["Category"] = true; if (Response.Cache.VaryByParams["Category"]) { //... }
或者可以使用HttpResponse.CacheControl完全阻止页面的缓存,但是它已经被弃用,而不是上面的Cache属性:
Response.CacheControl = "No-Cache";
编辑:或者你真的可以go nuts并且手动完成所有操作:
Response.ClearHeaders(); Response.AppendHeader("Cache-Control","no-cache"); //HTTP 1.1 Response.AppendHeader("Cache-Control","private"); // HTTP 1.1 Response.AppendHeader("Cache-Control","no-store"); // HTTP 1.1 Response.AppendHeader("Cache-Control","must-revalidate"); // HTTP 1.1 Response.AppendHeader("Cache-Control","max-stale=0"); // HTTP 1.1 Response.AppendHeader("Cache-Control","post-check=0"); // HTTP 1.1 Response.AppendHeader("Cache-Control","pre-check=0"); // HTTP 1.1 Response.AppendHeader("Pragma","no-cache"); // HTTP 1.1 Response.AppendHeader("Keep-Alive","timeout=3,max=993"); // HTTP 1.1 Response.AppendHeader("Expires","Mon,26 Jul 1997 05:00:00 GMT"); // HTTP 1.1