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

首頁 > 學院 > 開發設計 > 正文

asp.net 緩存

2019-11-17 01:28:58
字體:
來源:轉載
供稿:網友

asp.net 緩存

1.Output Caching

With output caching, the final rendered HTML of the page is cached. When the same page is requested again, the control objects are not created, the page life cycle doesn’t start, and none of your code executes. Instead, the cached HTML is served.

You can cache an ASP.NET page in two ways. The most common apPRoach is to insert the OutputCache directive at the top of your .aspx file,just below the Page directive, as shown here:

<%@ OutputCache Duration="20" VaryByParam="None" %>

The Duration attribute instructs ASP.NET to cache the page for 20 seconds.

OutputCache 指令實際上是asp.net向響應頭中輸出了三個響應頭:

image

You can set the VaryByParam attribute to * to indicate that the page uses the query  string and to instruct ASP.NET to cache separate copies of the page for different query string arguments:

<%@ OutputCache Duration="20" VaryByParam="*" %>

Now when you request the page with additional query string information, ASP.NET will examine the query string. If the string matches a previous request  and a cached copy of that page exists, it will be reused. Otherwise, a new copy of the p age will be created and cached separately.

2.Caching with Specific Query String Parameters

Setting VaryByParam to the wildcard asterisk (*) is unnecessarily vague. It’s usually better to specifically identify an important query string  variable by name. Here’s an example:

<%@ OutputCache Duration="20" VaryByParam="ProductID" %>

In this case, ASP.NET will examine the query string, looking for the ProductID parameter. Requests with different ProductID parameters  will be cached separately, but all other parameters will be ignored.

You can specify several parameters as long as you separate them with semicolons:

<%@ OutputCache Duration="20" VaryByParam="ProductID;CurrencyType" %>

In this case, ASP.NET will cache separate versions, provided the query string differs by ProductID or CurrencyType.


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 土默特左旗| 崇左市| 大理市| 泰宁县| 新和县| 阿瓦提县| 岐山县| 阿合奇县| 贡觉县| 来宾市| 兖州市| 阿克苏市| 双城市| 安龙县| 婺源县| 永安市| 罗山县| 鹤岗市| 双辽市| 盐源县| 无为县| 澳门| 航空| 张家港市| 措勤县| 新丰县| 巴里| 通渭县| 寿宁县| 大厂| 平陆县| 乳山市| 金阳县| 屏山县| 景宁| 平南县| 九龙城区| 清徐县| 婺源县| 中方县| 荔波县|