About Browser Caching
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 the Web site cache meta method
Do not cache<meta http-equiv< Span class= "pun" >= "pragma" Content= " No-cache "> <meta HTTP -equiv= "Cache-control" Content= "No-cache, must-revalidate" > <meta http-equiv< Span class= "pun" >= "expires" Content= "0" Span class= "pun" >>
Clean up temporary caches 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 is not recommended cleaning, but sometimes for security issues, need to clean up!
jquery Ajax clears the browser cache
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. ( "if-modified-since" , " 0 " Xmlhttp. ( "Cache-control" , " No-cache "); }, Success:function< Span class= "pun" > (response //operation } Async:false });
Method two, directly with Cache:false,
$.Ajax({ Url: ' www.haorooms.com ' Datatype: ' JSON ' , data :{}, Cache:false,< Span class= "PLN" > ifmodified :true , Success:function (response< Span class= "pun") { //operation } Async:false });
method Three: with random number, random number is also a good way to avoid caching!
URL 参数后加上 "?ran=" + Math.random(); //当然这里参数 ran可以任意取了
method Four: use random time, same as random number.
在 URL 参数后加上 "?timestamp=" + new Date().getTime();
Clean up with PHP back-end
Add header ("Cache-control:no-cache, Must-revalidate") to the server and so on (e.g. in PHP)
JS clear the browser cache several ways