Asp.net| Cache | Problem 1 cache asp.net page
1 programmatically manipulate the HttpCachePolicy class.
HttpCachePolicy.SetExpires
httpcachepolicy.setcacheability | NoCache
| Private
| Public
| Server
| ServerAndNoCache
| ServerAndPrivate
2<%@ OutputCache duration= varybyparam= "None"%>duration and VaryByParam properties are required.
2 Cache Some parts of the ASP.net page
The invariant part is cached without always requesting the server
Control, one version of the control is stored in the output cache for 120 seconds.
<%@ OutputCache duration= "varybyparam=" "None"%>
Or use the code-behind development method to develop a user control, the control version is stored in the output cache for 120 seconds when the following properties are included in the metadata of the class declaration.
[C #]
[Partialcaching (120)]
The above two methods will only cache the user control.
You can also use nesting to cache controls in a cached page or control.
You can program for an instance of the user control by declaring the ID attribute in the user control tag that you have specified for the output cache. However, in order for the code to work correctly, you must explicitly verify that the user control exists in the output cache.
!! Possible errors:
If you write code to manipulate a user control that contains the @ OutputCache directive, an error occurs.
In addition, if the page output cache is set to 100 seconds and the user control output cache is set to 50 seconds, the entire page is stored in the output cache for 100 seconds, regardless of the user control's shorter time settings.
However, if the page output cache storage duration is shorter than the user control store duration, the cached user output control is used until its storage time expires, even if the remainder of the page has been regenerated for a request. For example, if the page output cache is set to 50 seconds and the user control output cache is set to 100 seconds, the user control expires once for the remainder of the page to expire two times.
3) Caching Application Data
Allows you to store objects that require a large amount of server resources to be created in memory. It is implemented by the Cache class, which is specific to each application and its lifetime depends on the lifetime of the application. When the application restarts, the Cache object is recreated.
See Ms-help://ms specific content. Vscc.2003/ms. Msdnqtr.2003feb.2052/cpguide/html/cpconcacheapis.htm
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service