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.