After a long time, the program uses the jquery load method for the request. It is strange that the second request cannot be sent. Baidu, but I know that load is requested in get mode, so IE
It is cached. I searched for a lot of solutions on the Internet. I think the following is a comprehensive solution. It mainly includes client and server solutions.
1. Client Solution
Internet Access Policy: Internet Options-browsing history-settings-Temporary Internet Files can be changed
1: Add a random function after the page of the AJAX request. We can use the random time function.
Add t = Math. random () after the URL sent by javascript ()
For example: URL + "&" + "t =" + Math. random (); or new Date ();
2: Before XMLHttpRequest sends a request, add XMLHttpRequest. setRequestHeader ("If-Modified-Since", "0 ")
Generally, XMLHttpRequest won't be used directly.
You should be able to find such code
XXXXX. send (YYYYYY );
Then, convert it
XXXXX. setRequestHeader ("If-Modified-Since", "0 ");
XXXXX. send (YYYYYY );
Practice has proved that both methods are very effective.
1. Add the header ("Cache-Control: no-cache, must-revalidate") on the server ");
2. Add xmlHttpRequest. setRequestHeader ("If-Modified-Since", "0") before ajax sends a request ");
3. Add xmlHttpRequest. setRequestHeader ("Cache-Control", "no-cache") before ajax sends a request ");
4. Add "? Fresh = "+ Math. random (); // Of course, the fresh parameter can be any one here
5. The fourth method is similar to the third method. Add "? Timestamp = "+ new Date (). getTime (); // This method is recommended.
6. Replace GET with POST: Not recommended
2. server-side solutions:
Take Struts2 as an example:
Struts2 Server side usage
Xml Code
Copy codeThe Code is as follows:
<Package name = "json-nocache" extends = "json-default">
<Interceptors>
<Interceptor name = "cachingHeadersInterceptor" class = "com. ssa. pct. web. interceptor. CachingHeaderInterceptor"/>
<Interceptor-stack name = "defaultSecurityStack">
<Interceptor-ref name = "defaultStack"/>
<Interceptor-ref name = "cachingHeadersInterceptor"/>
</Interceptor-stack>
</Interceptors>
<Default-interceptor-ref name = "defaultSecurityStack"/>
</Package>
Java code
Copy codeThe Code is as follows:
Public class CachingHeaderInterceptor extends actinterceptor {
Private static final long serialVersionUID = 1L;
Public String intercept (ActionInvocation invocation) throws Exception {
ActionContext context = invocation. getInvocationContext ();
HttpServletResponse response = (HttpServletResponse) context. get (StrutsStatics. HTTP_RESPONSE );
If (response! = Null ){
Response. setHeader ("Cache-Control", "no-cache ");
Response. setHeader ("Pragma", "no-cache ");
Response. setHeader ("Expires", "-1 ");
}
Return invocation. invoke ();
}
}