Home  >  Article  >  Backend Development  >  Summary of methods to disable page caching in Asp.net

Summary of methods to disable page caching in Asp.net

高洛峰
高洛峰Original
2017-01-21 15:22:411242browse

1. Add

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

2 to the header of the Asp page 93f0f5c25f18dab9d176bd4f6de5d30e 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>

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>

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!
Statement:
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