About page caching issues. This problem has been found on the internet a lot. But found that all kinds of solutions, are separated from each other, there is no unified solution, I recently, also encountered the problem of page caching, according to the Web page cache of the answers to do a summary.
1. Server-side caching issues to prevent JSP page caching:
[Java]View Plaincopy
- <%
- Set the expiration date to a past time
- Response.setheader ("Expires", "Sat, 6 May 1995 12:00:00 GMT");
- Set http/1.1 No-cache Header
- Response.setheader ("Cache-control", "no-store,no-cache,must-revalidate");
- Set IE extension http/1.1 no-cache headers, users add themselves
- Response.AddHeader ("Cache-control", "post-check=0, pre-check=0");
- Sets the standard http/1.0 No-cache header.
- Response.setheader ("Pragma", "No-cache");
- %>
Of course, each page contains this code, which can be cumbersome to handle related pages by means of a custom filter
2. Prevent HTML page Caching
[XHTML]View Plaincopy < param name= "wmode" value= "Transparent" >
- <meta http-equiv= "pragma" content= "No-cache" >
- <meta http-equiv=< Span class= "Attribute-value" > "Cache-control" content= "No-cache" >
- <meta Http-equiv= "expires" content= "0" >
3. Preventing AJAX Caching
If, your page, has been set to prevent jsp,html page cache, but found that the page cache, always exists, it is necessary to consider whether the Ajax caused by the page cache.
1) set, such as after
The AJAX cache is generated for the following reasons: request, URL address:
In IE, if the URL submitted by XMLHttpRequest is the same as history, the cache is used and is not submitted to the server side at all. Therefore, the data that was just submitted cannot be taken.
For Ajax, the following settings are required:
Method One: add timestamp var url = BaseURL + "×tamp=" + New Date (). GetTime ();
Method Two: Plus random number var url = BaseURL + "&r=" + math.random ();
Summary: Original citation (http://www.javaeye.com/topic/150162)
In JSP pages, it is not possible to disable caching by using the HTML <meta> tag alone. Be sure to add
Response.setheader ("Pragma", "No-cache");
Response.setheader ("Cache-control", "No-cache");
Response.setdateheader ("Expires", 0);
Some people will say that this is not the same as the HTML tag settings. Indeed, I also think, but the practice proves that, without these words, just rely on HTML tag.
So when the action returns to the page, there are two things:
A, the returned page is not written on the above Forbidden cache statement (or only HTML tag is written). IE stores the URL link + page result (cache eabled). That's why we had the cache before.
b, the returned page is written with a forbidden cache statement. IE stores the URL link + page result (cache disabled). So that we can achieve the purpose we want. The request is actually sent every time.
Summary: Page cache does not have a unified solution, to specific problems specific analysis.
http://blog.csdn.net/oklzh/article/details/4445722
Http://www.blogjava.net/JAVA-HE/archive/2008/11/25/242420.html JS Write ()
Web Development JS---Page caching, JSP caching, HTML caching, Ajax caching, workarounds