国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

設(shè)置ASP.NET頁面不被緩存(客戶端/服務(wù)器端取消緩存方法)

2020-01-17 23:51:54
字體:
供稿:網(wǎng)友
復(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ù),比如:
http://xxx/xxx/xxx.jpg?p=xxx
IE是用過URL來控制緩存的,這樣就解決了
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 苍山县| 许昌县| 策勒县| 广安市| 福鼎市| 社旗县| 崇义县| 朝阳县| 和林格尔县| 柳江县| 镶黄旗| 鄂托克前旗| 丹巴县| 麻栗坡县| 璧山县| 开平市| 福安市| 当阳市| 北辰区| 平舆县| 白银市| 峡江县| 玉田县| 林甸县| 镶黄旗| 青河县| 五台县| 含山县| 丰县| 烟台市| 千阳县| 台东县| 镇康县| 吉安县| 禄劝| 崇左市| 石楼县| 含山县| 天峨县| 宝鸡市| 平远县|