Set the ASP.net page not to be cached (client/server-side Cancellation caching method) _ Practical Tips

Source: Internet
Author: User
Tags datetime
Copy Code code as follows:

<summary>
Set the page not to be cached
</summary>
private void Setpagenocache ()
{
Response.Buffer = true;
Response.ExpiresAbsolute = System.DateTime.Now.AddSeconds (-1);
Response.Expires = 0;
Response.CacheControl = "No-cache";
Response.appendheader ("Pragma", "No-cache");
}

1, cancel the cache
(2) Client cancellation
Copy Code code as follows:

<meta http-equiv= "Expires" content= "0" >
<meta http-equiv= "Cache-control" content= "No-cache" >
<meta http-equiv= "Pragma" content= "No-cache" >

(3) Service Appliance End Cancellation:
Server side:
Copy Code code as follows:

Response.Buffer = true;
Response.ExpiresAbsolute = DateTime.Now.AddDays (-1);
Response.Cache.SetExpires (DateTime.Now.AddDays (-1));
Response.Expires = 0;
Response.CacheControl = "No-cache";
Response.Cache.SetNoStore ();

Global Inside:
Copy Code code as follows:

protected void Application_BeginRequest (Object sender, EventArgs e)
{
HttpContext.Current.Response.Cache.SetNoStore ();
}
<%@ OutPutCache location= "None"%>

Page base class:
Copy Code code as follows:

public class Pagebase:page
{
Public pagebase () {}
protected override OnLoad (EventArgs e) {
Response.Cache.SetNoStore ();
Base. OnLoad ();
}
}

The easiest way to:-)
Learn csdn this forum, after the URL randomly add some useless parameters, such as:
Yun_qi_img/xxx.jpg?p=xxx
IE uses a URL to control the cache, which solves the
Related Article

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.