There are many ways to disable page caching. The most common method is to disable page caching directly on the client and write it directly in html. Another method is to disable page caching using net, next I will introduce you to you.
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 "; |