Method 1: Use the Response. Redirect Method on the server or the window. location. replace method on the front-end for navigation.
Method 2: disable ASP. NET page caching.
I recommend method 2 when necessary. Because the browser settings cannot be controlled during development. If you set Internet Explorer to never check and update the cache, it is difficult to avoid this problem. Therefore, use method 2 to make the temporary folder of Internet Explorer non-existent page files.
In addition, whether to disable the page cache depends on the actual situation. At first I thought that the page cache was only cached on the server, and then I read a blog
The significance of cache is large. In many cases, the pressure on the server can be greatly reduced. However, in the development process, we need to focus more on the needs and do not blindly set any attributes.
Prohibit directly in the browser
The code is as follows: |
Copy code |
<Html> <Head> <Meta http-equiv = "Expires" CONTENT = "0"> <Meta http-equiv = "Cache-Control" CONTENT = "no-cache"> <Meta http-equiv = "Pragma" CONTENT = "no-cache"> </Head> |
Disable page caching in asp.net
Server
The code is as follows: |
Copy code |
Response. Buffer = true; Response. ExpiresAbsolute = DateTime. Now. AddDays (-1 ); Response. Cache. SetExpires (DateTime. Now. AddDays (-1 )); Response. Expires = 0; Response. CacheControl = "no-cache "; Response. Cache. SetNoStore (); |
Global configuration
The code is as follows: |
Copy code |
Protected void Application_BeginRequest (Object sender, EventArgs e) { HttpContext. Current. Response. Cache. SetNoStore (); } |
Aspx page
The code is as follows: |
Copy code |
<% @ OutPutCache Location = "None" %> |
How to disable cache in C!
The code is as follows: |
Copy code |
Response. Buffer = true; Response. ExpiresAbsolute = System. DateTime. Now. AddSeconds (-1 ); Response. Expires = 0; Response. CacheControl = "no-cache "; |