After tossing for a long time, I used the jQuery load method to request the request in the program. It was strange why the request could not be sent for the second time. There is a Baidu, who knows that Load is requested in a get, so IE browser is
It cached. I searched a lot of solutions and a lot on the Internet. The following is a relatively comprehensive solution. It is mainly divided into client solutions and server solutions.
1. Client solution
IE access strategy: internet option-browsing historical records-setting-the option of temporary files of Internet
1: Add a random function after the page requested by Ajax, 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: Add xmlhttprequest.SetRequestHeader ("IF-Modify-SINCE", "0")
Under normal circumstances, the xmlhttprequest here will not be used directly
You should be able to find this code
Xxxxx.send (yyyyyy);
Then turn it into
Xxxxx.setRequestHeader ("iF-Modify-SINCE", "0");
Xxxxx.send (yyyyyy);
Practice has proved that both methods are very effective.
1. Add Header ("Cache-Control: No-Cache, Must-Revalidate") on the server
2. Add xmlhttprequest.setRequestHeader ("IF-Modified-Since", "0");
3. Add xmlhttprequest.setRequestHeader ("Cache-Control", "No-Cache");
4. Add "? Fresh =" + math.random () after the url parameter of Ajax; // Of course, the parameter fresh can be taken at arbitrarily
5. The fourth method is similar to the third. After adding the URL parameter, add "? TimesStamp =" + New Date (). Gettime (); // Recommend this method to use this method
6. Use post replace GET: not recommended
2. Server -side solution:
Take Struts2 as an example:
Struts2 server -side method
XML code
Copy code code as follows:
<package name = "json-nocache" extends = "json-default">
<Wterceptors>
<interceptor name = "cachingheadersinterceptor" />
<interceptor-stack name = "defaultSecurityStack">
<interceptor-ref name = "defaultStack" />
<interceptor-ref name = "cachingheadersinterceptor" />
</Internetor-Stack>
</interceptors>
<default-interceptor-ref name = "defaultSecurityStack" /> />
</package>
Java code
Copy code code as follows:
Public Class CachingheaderIntercePTOR EXTENDS ABSTRACTINTERCEPOR {
Private Static Final Long SerialVersionuid = 1L;
Public String Intercept
ActionContext Context = Invocation.getinvocontext ();
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 ();
}
}