ASP tips: five ways to disable page Cache

Source: Internet
Author: User

1. Add

Reference content is as follows:
Response. Buffer = true
Response. expiresabsolute = now ()-1
Response. expires = 0
Response. cachecontrol = "no-Cache"
Response. addheader "Pragma", "No-Cache"

2. Add in HTML code

Reference content is as follows:
<Head>
<Meta HTTP-EQUIV = "Pragma" content = "no-Cache">
<Meta HTTP-EQUIV = "cache-control" content = "no-Cache">
<Meta HTTP-EQUIV = "expires" content = "0">
</Head>


3. When you re-call the original page, you can pass a parameter href = "*****. asp? Random ()"

The first two methods are said to be invalid sometimes, and the third is to pass a random parameter during the jump! Because the cache of aspx is related to parameters, if the parameters are different, the cache will not be used, but the page will be regenerated. If a random parameter is passed every time, the cache can be avoided. This only applies to ASP & Asp.net

4. Use the following code on the JSP page to achieve no cache:

Reference content is as follows:
Response. setheader ("cache-control", "No-Cache"); /// HTTP 1.1
Response. setheader ("Pragma", "No-Cache"); // HTTP 1.0
Response. setdateheader ("expires", 0); // prevents caching at the Proxy Server

The code is added in the middle of

Reference content is as follows:
<Head>
<%
Response. setheader ("cache-control", "No-Cache"); /// HTTP 1.1
Response. setheader ("Pragma", "No-Cache"); // HTTP 1.0
Response. setdateheader ("expires", 0); // prevents caching at the Proxy Server
%>
</Head>

5. Window. Location. Replace ("webform1.aspx ");

The parameter is the page to be overwritten. The replace principle is to replace the page specified by the replace parameter with the current page.

This prevents users from clicking the back key. The Javascript script is used, for example:

Reference content is as follows:

A.html

<HTML>
<Head>
<Title> A </title>
<Script language = "JavaScript">
Function jump (){
Window. Location. Replace ("B .html ");
}
</SCRIPT>
</Head>
<Body>
<A href = "javascript: Jump ()"> B </a>
</Body>
</Html>

B .html

<HTML>
<Head>
<Title> B </title>
<Script language = "JavaScript">
Function jump (){
Window. Location. Replace ("a.html ");
}
</SCRIPT>
</Head>
<Body>
<A href = "javascript: Jump ()"> A </a>
</Body>
</Html>

The first four types only clear the cache, that is, temporary files stored in the Temporary Internet Files folder, and the fifth type is to use the jump page file to replace the current page file without clearing the cache, that is to say, Temporary Internet Files generate related temporary files. They are used together to clear the cache and are essential medicine. I have a record here, so I often look at it.

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.