After a while, the program uses the jquery load method to request, and it's strange why the request cannot be sent for the second time. Baidu A, who knows the load is to use get way to request, so IE browser to
It is cached. Online Search a lot of solutions, a bunch, below is I think more comprehensive solution. Mainly divided into client solutions and service-side solutions.
1. Client Solutions
IE Access policy: Internet Options--browsing history--setting--The Internet temporary files option is changed to every time you visit a Web page
1: After the Ajax requested page, add a random function, 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-modified-since", "0") before XMLHttpRequest send the request
In general, the XMLHttpRequest here will not be used directly
You should be able to find this code.
Xxxxx.send (YYYYYY);
So, just turn it into
Xxxxx.setrequestheader ("If-modified-since", "0");
Xxxxx.send (YYYYYY);
Practice has proved that both methods are very effective.
1, in the service End plus header ("Cache-control:no-cache, must-revalidate");
2, in the AJAX send the request before adding Xmlhttprequest.setrequestheader ("if-modified-since", "0");
3, in the AJAX send the request before adding Xmlhttprequest.setrequestheader ("Cache-control", "No-cache");
4, after the Ajax URL parameters plus "? fresh=" + math.random (); Of course, the parameter fresh can be arbitrarily taken.
5, the fourth method is similar to the third, after the URL parameter plus "? timestamp=" + New Date (). GetTime (); It is recommended to use this method
6. Replace get with post: not recommended
2. Server-Side solutions:
Take Struts2 as an example:
Struts2 Server End Usage
XML code
Copy Code code 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 Code code as follows:
public class Cachingheaderinterceptor extends Abstractinterceptor {
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 ();
}
}