Home > Backend Development > C#.Net Tutorial > Summary of methods to disable page caching in Asp.net

Summary of methods to disable page caching in Asp.net

高洛峰
Release: 2017-01-21 15:22:41
Original
1332 people have browsed it

1. Add

  Response.Buffer   =   True    
  Response.ExpiresAbsolute   =   Now()   -   1    
  Response.Expires   =   0    
  Response.CacheControl   =   "no-cache"    
  Response.AddHeader   "Pragma",   "No-Cache"
Copy after login

2 to the header of the Asp page 2. Add

  <HEAD>    
  <META   HTTP-EQUIV="Pragma"   CONTENT="no-cache">    
  <META   HTTP-EQUIV="Cache-Control"   CONTENT="no-cache">    
  <META   HTTP-EQUIV="Expires"   CONTENT="0">    
  </HEAD>
Copy after login

3 to the HtML code. 3. Pass a parameter to the page when calling the original page again. Href="****.asp?random()"
The first two methods are said to sometimes fail, while the third method is to pass a random parameter when jumping! Because aspx's cache is related to parameters, if the parameters are different, the cache will not be used, but the page will be regenerated. Passing a random parameter each time can avoid using the cache. This only applies to asp&asp.net

4. window.location.replace("WebForm1.aspx");
The parameter is the page you want to cover. The principle of replace is to replace the replace parameter with the current page specified page.
This prevents the user from clicking the back key. A javascript script is used, for example:

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>
Copy after login

The first 3 methods only clear the cache, which is the temporary file stored in the Temporary Internet Files folder, while the 4th method only clears the cache. The jump page file is used to replace the current page file without clearing the cache, which means that Temporary Internet Files generates related temporary files.

For more articles on how to disable page caching in Asp.net, please pay attention to the PHP Chinese website!
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template