国产探花免费观看_亚洲丰满少妇自慰呻吟_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.


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 乐都县| 威宁| 广昌县| 扎囊县| 务川| 肥乡县| 读书| 台江县| 澄城县| 金坛市| 拉萨市| 湖南省| 宁夏| 山东| 和顺县| 云安县| 奉节县| 涟源市| 合水县| 诸城市| 视频| 招远市| 金平| 乌兰察布市| 竹溪县| 林西县| 广德县| 松潘县| 大厂| 九江市| 通州区| 托克逊县| 嫩江县| 友谊县| 阳原县| 新宁县| 织金县| 阳曲县| 七台河市| 呼伦贝尔市| 宁明县|