现在的位置: 首页 > 综合 > 正文

Asp.net取消页面缓存的几种方法

2013年10月01日 ⁄ 综合 ⁄ 共 691字 ⁄ 字号 评论关闭

1. 客户端取消

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

2. 服务器端取消:

服务器端:
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();

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

4. 页面基类:
public   class   PageBase   :   Page
{
public   PageBase()   {}

protected   override   OnLoad(   EventArgs   e   )   {
Response.Cache.SetNoStore();
base.OnLoad();
}
}

抱歉!评论已关闭.