How to clear the background code of the page cache in ASP.

Source: Internet
Author: User
Tags httpcontext

How to empty the background code of the page cache in ASP. (because only the GET request will have a cache)
Description: When using AJAX, there is a good chance that the same request will occur here. For example, Buttona modified the data, and BUTTONB export data, if the two buttons are Ajax technology to do, in fact buttonb after the second click, will not re-get the data from the database, but directly to the cache page sent to the client. Well, it's good to do it, but it's not what we want. The so-called use of Ajax produces unpredictable results, which may be part of it. So all I have to do is empty the cache every time a GET request is made, and then generate the page to send to the client. The code is as follows:
#region emptying the client page cache: public static void Clearclientpagecache () {HttpContext.Current.Response.Buffer = true; HttpContext.Current.Response.Expires = 0; HttpContext.Current.Response.ExpiresAbsolute = DateTime.Now.AddDays (-1); HttpContext.Current.Response.AddHeader ("Pragma", "no-cache"); HttpContext.Current.Response.AddHeader ("Cache-control", "private"); HttpContext.Current.Response.CacheControl = "No-cache"; #endregion can be called where needed.

How to clear the background code of the page cache in ASP.

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.