Several Methods for clearing page cache in ASP. NET

Source: Internet
Author: User

When you use the dialog mode in Asp.net, you will find that each time the page is opened with the same content, the page content is not refreshed, this is the reason for the cache,

The solution is as follows:

First, ASP. NET clears the page cache.
Response. Buffer = true;
Response. expiresabsolute = system. datetime. Now. addseconds (-1 );
Response. expires = 0;
Response. cachecontrol = "no-Cache ";
Response. addheader ("Pragma", "No-Cache ");

The second method is the HTML method.
<Head>
<Meta HTTP-EQUIV = "Pragma" content = "no-Cache">
<Meta HTTP-EQUIV = "cache-control" content = "no-Cache">
<Meta HTTP-EQUIV = "expires" content = "0">
</Head>

The third is to pass a parameter to the page when calling the original page again: href = "*****. aspx? Random ()"

The last option is to disable caching on the page.

the rational use of cache in Web development can effectively improve the performance of websites. However, in some cases, cache may cause many problems.
For example: the cache may cause repeated data submission, the verification code image cannot be correctly displayed . In this case, we need to disable the page cache function.
our common practice is to send a "no-Cache" command, but we found that this command is valid for IE during actual use, but it is not effective for Firefox because Firefox does not cache HTTPS pages but HTTP pages. This is a bug in Firefox and the solution is simple, instead of No-cache, use no-store to send the no-store and no-Cache commands
Processing Method in Asp.net, add the following Code
response. cache. setcacheability (system. web. httpcacheability. nocache);
response. cache. setnostore ();
from http://www.notsee.info/tech/tech.xml

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.