人妻无码中文字幕永久在线,99RE6这里有精品热视频,国产成人综合色就色综合 ,蜜臀av在线观看

新聞建站cms系統(tǒng)、政府cms系統(tǒng)定制開(kāi)發(fā)

廣州網(wǎng)站建設(shè)公司-閱速公司

asp.net新聞發(fā)布系統(tǒng)、報(bào)紙數(shù)字報(bào)系統(tǒng)方案
/
http://www.jdki.com.cn/
廣州網(wǎng)站建設(shè)公司
您當(dāng)前位置:首頁(yè)>ASP.NET MVC

ASP.NET MVC

使用自定義字符串對(duì)頁(yè)的各個(gè)版本進(jìn)行緩存GetVaryByCustomString

發(fā)布時(shí)間:2010/7/24 11:07:46  作者:  閱讀:1139  

廣告:

使用自定義字符串對(duì)頁(yè)的各個(gè)版本進(jìn)行緩存:

protected void Page_Load(object sender, EventArgs e)
{
Response.Cache.SetExpires(DateTime.Now.AddMinutes(1.0));
Response.Cache.SetCacheability(HttpCacheability.Public);
Response.Cache.SetValidUntilExpires(true);
Response.Cache.SetVaryByCustom("minorversion");
}


protected void Page_Load(object sender, EventArgs e)
{
Response.Cache.SetExpires(DateTime.Now.AddMinutes(1.0));
Response.Cache.SetCacheability(HttpCacheability.Public);
Response.Cache.SetValidUntilExpires(true);
Response.Cache.VaryByHeaders["Accept-Language"] = true;
}


<%@ outputcache duration="60" varybyparam="none" varybyheader="accept-language" %>

VaryByHeader-- 更據(jù)HTTP頭信息改變緩存區(qū)內(nèi)容(不支持用戶(hù)控件輸出緩存)


<%@ OutputCache Duration="#ofseconds"
Location="Any | Client | Downstream | Server | None |
ServerAndClient "
Shared="True | False"
VaryByControl="controlname"
VaryByCustom="browser | customstring"
VaryByHeader="headers"
VaryByParam="parametername"
CacheProfile="cache profile name | ''"
NoStore="true | false"
SqlDependency="database/table name pair | CommandNotification"
%>


VaryByCustom
表示自定義輸出緩存要求的任意文本。如果賦予該屬性的值為 browser,緩存將隨瀏覽器名稱(chēng)和主要版本信息的不同而異。如果輸入自定義字符串,則必須在應(yīng)用程序的 Global.asax 文件中重寫(xiě) GetVaryByCustomString 方法。


VaryByControl
一個(gè)分號(hào)分隔的字符串列表,用于更改用戶(hù)控件的輸出緩存。這些字符串代表用戶(hù)控件中聲明的 ASP.NET 服務(wù)器控件的 ID 屬性值


VaryByCustom="UserID"自定義

第一個(gè):
public override string GetVaryByCustomString(HttpContext context, String arg) {

string cacheKey = "";

switch(arg) {

case "CategoryPageKey":

if (Request.IsAuthenticated == true) {

cacheKey = "QQQ" + context.Request.QueryString["category_id"] + context.Request.QueryString["requestedPage"];

}

else {

cacheKey = "AAA" + context.Request.QueryString["category_id"] + context.Request.QueryString["requestedPage"];

}

break;

case "UserID" :

if (Request.IsAuthenticated == true) {

cacheKey = "UserID_In";

}

else {

cacheKey = "UserID_Out";

}

break;

}

return cacheKey;

}

第二個(gè):

global.asax 文件中:
<script>
public override string GetVaryByCustomString(HttpContext context, string arg){
If (arg = "minorversion "){
Return "Version= " + context.Request.Browser.MinorVersion.ToString();
}
}
</script>


第三個(gè):
<%@ Application Language="C#" %>

<script runat="server">

public override string GetVaryByCustomString(HttpContext context, string arg)
{
if (arg.ToLower() == "prefs ")
{
HttpCookie cookie = context.Request.Cookies["Language"];
if (cookie != null)
{
return cookie.Value;
}
}
return base.GetVaryByCustomString(context, arg);
}

void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup

}

</script>

廣告:

相關(guān)文章
使用自定義字符串對(duì)頁(yè)的各個(gè)版本進(jìn)行緩存GetVaryByCustomString
cms新聞系統(tǒng)購(gòu)買(mǎi)咨詢(xún)
掃描關(guān)注 廣州閱速軟件科技有限公司
掃描關(guān)注 廣州閱速科技