About Browser Caching
Browser caching, sometimes we need him, because he can improve Web performance and browser speed, improve site performance. But sometimes we have to clear the cache, because the cache may be bad, there are some wrong data. such as the stock site real-time updates, such as the site is not cached, like some sites are rarely updated, there is a cache or better. Today, there are several ways to clear the cache.
Several ways to clean up your Web site cache
Meta method
Do not cache
<meta http-equiv= "Pragma" content= "No-cache" >
<meta http-equiv= "Cache-control" content= "No-cache, must-revalidate" >
<meta http-equiv= "Expires" content= "0" >
Clean up temporary caching of form forms
<body onload= "Javascript:document.yourFormName.reset ()" >
In fact, the form of the cache for our writing is still helpful, the general situation does not recommend cleaning, but sometimes for security issues, need to clean up!
jquery Ajax Clear Browser cache
mode one: use AJAX to request the latest files of the server, plus the request headers if-modified-since and Cache-control, as follows:
$.ajax ({
URL: ' www.jb51.net ',
dataType: ' json ',
data:{},
beforesend:function (xmlHttp) {
Xmlhttp.setrequestheader ("If-modified-since", "0");
Xmlhttp.setrequestheader ("Cache-control", "No-cache");
},
success:function (response) {
//action
}
Async:false
});
method Two, directly using Cache:false,
$.ajax ({
URL: ' www.jb51.net ',
dataType: ' json ',
data:{},
Cache:false,
ifmodified:true,
success:function (response) {
//Operation
}
async:false
});
method Three: with random number, random number is also a good way to avoid caching!
URL parameter Plus "? ran=" + math.random (); Of course, the parameter ran can be arbitrarily taken.
method Four: use random time, same as random number.
After the URL parameter, add "? timestamp=" + New Date (). GetTime (); Use PHP back-end cleanup
Header ("Cache-control:no-cache, Must-revalidate") at the service End (""), etc. (as in PHP)
Above this clear browser cache several methods summary (must SEE) is small series share to everybody's content, hoped can give everybody a reference, also hoped that everybody supports the cloud habitat community.