清除頁麵緩存
在開發中有時並不希望頁麵被緩存,特別是彈出式窗體,可以使用一下方法處理,將頁麵設置為不緩存。方法一:在頁麵文件的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()"
最後更新:2017-04-02 22:16:10