This article mainly introduces two solutions for xmlhttp cache clearing. For more information, see.
Method 1: add the If-Modified-Since Header
When xmlhttp is called for multiple times, it always displays the cache page. It does not work if you try to add the corresponding http header to php or asp, so it does not need to be cached !!
Now we can finally find a way to send an If-Modified-Since Header after xmlhttp. open. The Code is as follows:
Xmlhttp. setRequestHeader ('If-Modified-Since ', '0 ');
XmlHttp. onreadystatechange = stateChanged;
XmlHttp. open ("GET", url, true );
XmlHttp. setRequestHeader ('If-Modified-Since ', '0 ');
XmlHttp. send (null );
Method 2: Add parameters after the request URL
Because IE caches the same URL request by default, adding unique and differentiated parameters to the URL of each request can bypass the IE cache problem.
Js: URL = "http: // host/a. php" + "? "+ Math. random ();
Vbs: URL = "http: // host/a. php "&"? "& Timer ()
// Var url = "ResponseContentPageScore. aspx? Key = "+ Math. round (Math. random () * 100) +" & CD = "+ inputContent;
Var url = "ResponseContentPageScore. aspx? Key = "+ new Date (). getTime () +" & CD = "+ inputContent;