設(shè)置ASP.NET頁(yè)面不被緩存(客戶端/服務(wù)器端取消緩存方法)
更新時(shí)間:2013年06月24日 16:18:09 作者:
設(shè)置頁(yè)面不被緩存:客戶端取消緩存、服務(wù)器具端取消緩存的具體實(shí)現(xiàn)代碼如下感興趣的朋友可以參考下哈,希望對(duì)大家有所幫助
復(fù)制代碼 代碼如下:
/// <summary>
/// 設(shè)置頁(yè)面不被緩存
/// </summary>
private void SetPageNoCache()
{
Response.Buffer = true;
Response.ExpiresAbsolute = System.DateTime.Now.AddSeconds(-1);
Response.Expires = 0;
Response.CacheControl = "no-cache";
Response.AppendHeader("Pragma", "No-Cache");
}
1、取消緩存
(2)客戶端取消
復(fù)制代碼 代碼如下:
<html>
<head>
<meta http-equiv="Expires" CONTENT="0">
<meta http-equiv="Cache-Control" CONTENT="no-cache">
<meta http-equiv="Pragma" CONTENT="no-cache">
</head>
(3)服務(wù)器具端取消:
服務(wù)器端:
復(fù)制代碼 代碼如下:
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里面:
復(fù)制代碼 代碼如下:
protected void Application_BeginRequest(Object sender, EventArgs e)
{
HttpContext.Current.Response.Cache.SetNoStore();
}
<%@ OutPutCache Location="None"%>
頁(yè)面基類:
復(fù)制代碼 代碼如下:
public class PageBase : Page
{
public PageBase() {}
protected override OnLoad( EventArgs e ) {
Response.Cache.SetNoStore();
base.OnLoad();
}
}
最簡(jiǎn)單的辦法 :-)
學(xué)CSDN的這個(gè)論壇,在URL后面隨機(jī)的加一些沒用的參數(shù),比如:
http://xxx/xxx/xxx.jpg?p=xxx
IE是用過URL來(lái)控制緩存的,這樣就解決了
您可能感興趣的文章:
- asp.net頁(yè)面SqlCacheDependency緩存實(shí)例
- Asp.net禁用頁(yè)面緩存的方法總結(jié)
- ASP.NET頁(yè)面在IE緩存的清除辦法
- ASP.NET 4中的可擴(kuò)展輸出緩存(可以緩存頁(yè)面/控件等)
- asp.net 使用駐留在頁(yè)面中的Cache緩存常用可定時(shí)更新的數(shù)據(jù)
- asp.net 頁(yè)面輸出緩存
- ASP.net Substitution 頁(yè)面緩存而部分不緩存的實(shí)現(xiàn)方法
- ASP.NET 2.0中的頁(yè)面輸出緩存
- 讓html頁(yè)面不緩存js的實(shí)現(xiàn)方法
- ASP.NET頁(yè)面緩存常見的4種方式
相關(guān)文章
ASP.NET TreeView讀取數(shù)據(jù)庫(kù)實(shí)例
這篇文章主要介紹了ASP.NET TreeView讀取數(shù)據(jù)庫(kù)實(shí)例,有需要的朋友可以參考一下2013-11-11asp.net 產(chǎn)生隨機(jī)顏色實(shí)現(xiàn)代碼
asp.net 隨機(jī)顏色產(chǎn)生實(shí)現(xiàn)代碼,需要的朋友拿過去測(cè)試一下。2009-11-11