Summary of Solutions to Ajax cache problems, and ajax cache Summary
1. Add anyAjaxObj. setRequestHeader ("If-Modified-Since", "0") before ajax sends a request ").
2. Add anyAjaxObj. setRequestHeader ("Cache-Control", "no-cache") before ajax sends a request ").
3. Add a random number after the URL: "fresh =" + Math. random ();.
4. Add the time after the URL: "nowtime =" + new Date (). getTime ();.
5. If jQuery is used, you can directly set $. ajaxSetup ({cache: false }). In this way, all the ajax operations on the page will execute this statement without the need to save cache records.
AJAX cache in IE
If AJAX is not used in combination with Web Services, it simply reads another page, which is the same effect for another page to be opened directly from a browser, therefore, your problem has nothing to do with the AJAX method itself, because AJAX is only responsible for reading. As for what the page provides to him, you need to solve the cache problem from the page itself.
The default cache settings are different for several browsers. You can directly add a disabled cache on the page.
HTML
<META HTTP-EQUIV = "pragma" CONTENT = "no-cache">
<META HTTP-EQUIV = "Cache-Control" CONTENT = "no-cache, must-revalidate">
<META HTTP-EQUIV = "expires" CONTENT = "Mon, 23 Jan 1978 12:52:30 GMT">
ASP
<%
Response. Expires =-1
Response. ExpiresAbsolute = Now ()-1
Response. cachecontrol = "no-cache"
%>
PHP
Header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT ");
Header ("Cache-Control: no-cache, must-revalidate ");
Header ("Pragma: no-cache ");
JSP
Response. setHeader ("Pragma", "No-Cache ");
Response. setHeader ("Cache-Control", "No-Cache ");
Response. setDateHeader ("Expires", 0 );
How to disable cache in C!
Response. Buffer = true;
Response. ExpiresAbsolute = System. DateTime. Now. AddSeconds (-1 );
Response. Expires = 0;
Response. CacheControl = "no-cache ";
Above
Jquery ajax cache Problems
Does the image name remain unchanged? Add a parameter to the image src, as shown in figure
$ ("Img"). attr ("src", "test.jpg? Rand = "+ new Date (). getTime () + Math. random ());