asp.net禁止页面缓存,适合各种浏览器

分类:.Net知识问答| 发布:camnprbubuol| 查看: | 发表时间:2011/5/9

客户端:

<html>
<head>
<meta http-equiv="Expires" CONTENT="0">
<meta http-equiv="Cache-Control" CONTENT="no-cache">
<meta http-equiv="Pragma" CONTENT="no-cache">
</head>

服务器端:
Response.Buffer = true;
Response.ExpiresAbsolute = DateTime.Now.AddDays(-1);
Response.Cache.SetExpires(DateTime.Now.AddDays(-1));
Response.Expires = 0;
Response.CacheControl = "no-cache";
Response.Cache.SetNoStore();

Global:
protected void Application_BeginRequest(Object sender, EventArgs e)
{
HttpContext.Current.Response.Cache.SetNoStore();
}
<%@ OutPutCache Location="None"%>

 

ASP.NET
Response.Cache.SetCacheability(HttpCacheability.NoCache);
ASP:[在.net下也行]
Response.Expires = 0;
Response.Buffer = true;
Response.ExpiresAbsolute = DateTime.Now.AddSeconds(-1);
Response.AddHeader("pragma", "no-cache");
Response.CacheControl = "no-cache";

//也就是通过禁止缓存,来实现重新刷新,这样页面即使在遇到back,也会自动刷新

365据说看到好文章不转的人,服务器容易宕机
原创文章如转载,请注明:转载自郑州网建-前端开发 http://camnpr.com/
本文链接:http://camnpr.com/net-wiki/288.html