First, CSS and JS why with parameters (such as. css?t= and. js?t=) How to get the code
CSS and JS with parameters (such as. css?t= and. js?t=)
There are two possible uses of parameters:
The first, the script does not exist, but the server side dynamically generated, so with a version number, to show the difference. That is, the code above is equivalent to a file but the browser thinks he is a version of the file.
Second, the client will cache these CSS or JS files, so each time you upgrade the JS or CSS file, change the version number, the client browser will download the new JS or CSS files, brush the role of caching.
The second is the most, and there may be two of them at the same time.
The version number, can be a random number, can also be an incremented value, a large version of the version of the way, or according to the script generation time to write, such as is accurate to generate the script seconds, and 2.3.3 is a large version of the small version of the way.
Second, 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
<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
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.haorooms.com ',
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.haorooms.com ',
dataType: ' json ',
data:{},
Cache:false,
ifmodified: True,
success:function (response) {
//Operation
}
async:false
});
Method Three: 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 from the
eg:
<script>
document.write ("<s" + "Cript type= ' text/javascript '" src= "/js/") Test.js? " +math.random () + "' ></scr" + "ipt>");
</script>
Other similar, simply add +math.random to the address ()
Method Four: Use random time, same as random number.
Use PHP back-end cleanup
Header ("Cache-control:no-cache, Must-revalidate") at the service End (""), etc. (as in PHP)
Method Five:
5, Window.location.replace ("WebForm1.aspx");
The parameter is the page you want to overwrite, and the principle of replace is to substitute the page specified by the Replace parameter with the current page. This prevents the user from clicking the Back button.
The JavaScript script is used, for example: A.html The following is a quote fragment:
Reprint Address: HTTP://WWW.HAOROOMS.COM/POST/JS_LLQ_HC