Asp.net @ OutputCache

Source: Internet
Author: User

Let's go through all the attributes of @ outpucache and share 11 attributes. This command can be used for pages (. asp tutorial x) and user controls (. ascx)
Attribute
Duration
Page or user control cache time, in seconds, you can set this attribute on the page or control to create a cache expiration policy, this attribute is required.
Varybyparam
The string list separated by semicolons. Whether to change according to a parameter or not, either varybycontrol or varybycontrol is required. If it does not change, set the value to none. Otherwise, set it to * or change the parameter name (the get or post parameter ).
Varybycontrol
The string list separated by semicolons is limited to user controls. The value of the string list is the ID of the server control.
Location: the cache location. The default value is any. This attribute is limited to. aspx files. The optional values include any, client, downstream, server, none, and serverandclient.
Shared this attribute is limited to. ascx files. The default value is false. Can a user control be shared by multiple pages.
Cacheprofile you can configure a cache setting in web. config so that you can share this cache setting later to facilitate unified modification and do not support user controls.
Nostore is not very clear about what to use. On msdn, it is determined whether to assist in storage of sensitive information.
Varybycontentencodings is also a comma-separated string list. It determines whether to cache different versions based on the accept-encodeing http header.
Varybyheader determines whether to store versions based on http headers. It is also a semicolon-separated string list.
Through this attribute, you can customize how to cache pages.
Sqldependency specifies a dependency for the current cache. When a change occurs, the cache of the current page or control is deleted from the cache.
 
It is the 11 attributes listed above. In most cases, you only need to set the duration and varybyparam attributes. For example:

<% @ Outputcache duration = "100" varybyparam = "none" %>

No location specified in the preceding command is cached on both the client and server by default. If querystring of the page is changed, the results are directly returned from the cache, therefore, do not set this setting on pages that need to return different content based on parameters. You can use the following method:

<% @ Outputcache duration = "100" varybyparam = "*" %>

The above duration Attribute is mandatory, but it is not actually necessary. If you do not want to use the cache, you do not have to write ^ _ ^, as shown below, to disable the current page cache:
<% @ Outputcache location = "none" %>

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.