這篇文章主要講解了“怎么設(shè)置ASP.NET頁面不被緩存”,文中的講解內(nèi)容簡(jiǎn)單清晰,易于學(xué)習(xí)與理解,下面請(qǐng)大家跟著小編的思路慢慢深入,一起來研究和學(xué)習(xí)“怎么設(shè)置ASP.NET頁面不被緩存”吧!

復(fù)制代碼 代碼如下:
/// <summary>
/// 設(shè)置頁面不被緩存
/// </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"%>
頁面基類:
復(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ù),比如:
/tupian/20230522/404.html
IE是用過URL來控制緩存的,這樣就解決了
感謝各位的閱讀,以上就是“怎么設(shè)置ASP.NET頁面不被緩存”的內(nèi)容了,經(jīng)過本文的學(xué)習(xí)后,相信大家對(duì)怎么設(shè)置ASP.NET頁面不被緩存這一問題有了更深刻的體會(huì),具體使用情況還需要大家實(shí)踐驗(yàn)證。這里是創(chuàng)新互聯(lián)網(wǎng)站建設(shè)公司,,小編將為大家推送更多相關(guān)知識(shí)點(diǎn)的文章,歡迎關(guān)注!
當(dāng)前名稱:怎么設(shè)置ASP.NET頁面不被緩存-創(chuàng)新互聯(lián)
分享路徑:http://chinadenli.net/article4/cddooe.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供做網(wǎng)站、軟件開發(fā)、云服務(wù)器、定制開發(fā)、營(yíng)銷型網(wǎng)站建設(shè)、響應(yīng)式網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容