How to: set page cache by programming

Source: Internet
Author: User

The cache of a page or user control refers to whether a page can be cached on a device within the response lifecycle of the page. These devices on the cache page include the browser that sends the request, the web server that responds to the request, and any device that can execute the cache in the request or response stream, such as the proxy server.

If the application determines the cacheability Based on runtime conditions (such as reading request headers), you can set the cacheability programmatically. For more information, see set page cache.

Set page cache by programming
  • In the Page code, call Object Attribute Method.

    The following code willCache-controlSet the HTTP header .

    Response.Cache.SetCacheability(HttpCacheability.Public);

    If Or PassSetcacheabilityTo prevent the requested browser from caching a page in its own history folder, when a user clicks the back or forward button at any time, the new version of the request response. By calling Attribute Method, andAllowParameter transferTrueValue, You can override this behavior according to the conditions.

    If caching is set to DivisionNocacheOrServerandnocacheAny other value, ASP. NET will ignoreSetallowresponseinbrowserhistoryThe value set by the method.

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.