Summary of Asp. net methods for disabling page caching

  • 2020-12-05 17:09:25
  • OfStack

1. At the head of Asp page < head > join


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

2. Add in HtML code

  <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 calling the original page again, pass 1 parameter Href="***.asp? random()"
The first two methods are said to fail sometimes, while the third is to pass a random parameter at jump time! Because aspx's cache is parameter dependent, if the parameters are different, the cache is not used, but the page is regenerated, passing one random parameter each time can avoid using the cache. This applies only to asp & asp.net


4, window. location. replace (" WebForm1. aspx ");
The parameter is the page you want to overwrite, and the principle of replace is to replace the page specified by the replace parameter with the current page.
This prevents the user from hitting the back key. The javascript script is used, 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> 

The first three simply empty cache, the temporary file stored in the Temporary Internet Files folder, while the fourth one replaces the current page file with a jump page file and does not empty cache, that is, Temporary Internet Files produces the relevant temporary file.


Related articles: