`
bulote
  • 浏览: 1310347 次
文章分类
社区版块
存档分类
最新评论

清除页面缓存

 
阅读更多
在开发中有时并不希望页面被缓存,特别是弹出式窗体,可以使用一下方法处理,将页面设置为不缓存。

方法一:在页面文件的HEAD中添加
<HEAD>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="0">
</HEAD>

方法二 :在后端代码中添加,建议放在 Page_Load 事件中
Page.Response.Buffer = false;
Page.Response.Cache.SetNoStore();



C#清除页面缓存
private void SetPageNoCache()
{
Response.Buffer = true;
Response.ExpiresAbsolute = System.DateTime.Now.AddSeconds(-1);
Response.Expires = 0;
Response.CacheControl = "no-cache";
Response.AddHeader("Pragma", "No-Cache");
}

(1) Response.Buffer = true;
Response.ExpiresAbsolute = System.DateTime.Now.AddSeconds(-1);
Response.Expires = 0;
Response.CacheControl = "no-cache";
Response.AddHeader("Pragma", "No-Cache");

(2) HTML方法

<meta http-equiv="Pragma" content="no-cache"><meta http-equiv="Cache-Control" content="no-cache"><meta http-equiv="Expires" content="0">

(3) 重新调用原页面的时候在给页面传一个参数: href="****.ASPX?random()"
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics