When you use the dialog mode in asp.net, you will find that each time the page is opened with the same content, the page content is not refreshed, this is the reason for the cache,
The solution is as follows:
First, ASP. NET clears the page cache.
| The code is as follows: |
Copy code |
Response. Buffer = true; Response. ExpiresAbsolute = System. DateTime. Now. AddSeconds (-1 ); Response. Expires = 0; Response. CacheControl = "no-cache "; Response. AddHeader ("Pragma", "No-Cache "); |
The second method is the HTML method.
| The code is as follows: |
Copy code |
<HEAD> <META HTTP-EQUIV = "Pragma" CONTENT = "no-cache"> <META HTTP-EQUIV = "Cache-Control" CONTENT = "no-cache"> <META HTTP-EQUIV = "Expires" CONTENT = "0"> </HEAD> |
The third is to pass a parameter to the page when calling the original page again: href = "*****. ASPX? Random ()"
The last option is to disable caching on the page.
The rational use of cache in web development can effectively improve the performance of the website. However, in some cases, the existence of cache may cause many problems.
For example, the cache may cause repeated data submission and incorrect display of verification code images. In this case, we need to disable the page cache function.
Our common practice is to send a "no-cache" command, but in actual use, we found that this command is valid for IE, but not for Firefox, this is because Firefox does not cache HTTPS pages but will still cache HTTP pages. This is a BUG in Firefox. The solution is simple, that is, replacing no-cache with no-store, send no-store and no-cache commands at the same time
In ASP.net, add the following code to the page that does not require caching:
Response. Cache. SetCacheability (System. Web. HttpCacheability. NoCache );
Response. Cache. SetNoStore ();