First, CSS and JS Why with parameters (shaped like. css?t= and. js?t=) How to get the code
CSS and JS with parameters (shaped like. css?t= and. js?t=)
There are two possible ways to use parameters:
First, the script does not exist, but the server is dynamically generated, so with a version number, to show the difference. That is, the above code 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 files, change the version number, the client browser will re-download the new JS or CSS files, the role of the brush cache.
The second situation is the most, and it is possible that both exist simultaneously.
The version number can be a random number, or it can be an incremented value, a large version of the iteration, or write according to the script's generation time, for example, to generate the script in seconds, and 2.3.3 is the way to a large version of the iteration.
Second, about the browser cache
Browser cache, sometimes we need him, because he can improve website performance and browser speed, improve website performance. But sometimes we have to clear the cache, because the cache can be bad and there are some wrong data. such as stock site real-time updates, such as the site is not cached, like some sites are rarely updated, there is a cache or better. Here are a few ways to clear the cache today.
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 caches of form forms
Method One: Use Ajax to request the latest server files, and add 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){ //操作 } async:false });
Method two, directly with Cache:false,
$.ajax({ url:‘www.haorooms.com‘, dataType:‘json‘, data:{}, cache:false, ifModified :true , success:function(response){ //操作 } async:false });
Method Three: With random number, random number is also a good way to avoid caching!
URL 参数后加上 "?ran=" + Math.random(); //当然这里参数 ran可以任意取了eg:<script> document.write("<s"+"cript type=‘text/javascript‘ src=‘/js/test.js?"+Math.random()+"‘></scr"+"ipt>"); </script>其他的类似,只需在地址后加上+Math.random() 注意:因为Math.random() 只能在Javascript 下起作用,故只能通过Javascript的调用才可以
Method Four: Use random time, same as random number.
"?timestamp=" + new Date().getTime();
Clean up with PHP back-end
header("Cache-Control: no-cache, must-revalidate");等等(如php中)
Method Five:
5, Window.location.replace ("WebForm1.aspx"); The parameter is the page you want to overwrite, and replace replaces the page specified by the Replace parameter with the current page. This prevents the user from clicking the back key. Using JavaScript scripts, for example: A.html The following is a reference fragment:<Html><Head><Title>a</Title><ScriptLanguage="JavaScript" > functionJump() {Window.location.replace ("B.html"); }</Script></Head><Body><Ahref="Javascript:jump ()" >b</A></Body></Html> b.html The following is a reference fragment:<Html><Head><Title>b</Title><ScriptLanguage= "javascript" > function jump () {Window.location.replace ( "a.html"); } </script> </ head> <body> <a href= "Javascript:jump ()" >a</a> Span class= "Hljs-tag" ></body> </ html>
Go from: http://www.cnblogs.com/Mr-Rocker/p/6031096.html
JS clears the browser cache several ways