若是不讓瀏覽器對頁面進行緩存,能夠加這麼幾行代碼:php
<HEAD>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="0">
</HEAD>
php作法:css
<?php
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . 'GMT');
header('Cache-Control: no-cache, must-revalidate');
header('Pragma: no-cache');
?>
HTML5 應用緩存技術
首先在首頁裏面聲明瞭:html
<html manifest="index.appcache">
而後在響應的文件:java
CACHE MANIFEST
CACHE:
webhuancun.php
NETWORK:
style.css3
webworker:
多線程處理,可讓另一個js文件來處理一些東西,而後返回主js文件,看下面的圖:
web
而後咱們能夠記錄一下三個文件的寫法,注意這只是一個小例子:瀏覽器
index.html:
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<script src="index.js"></script>
</head>
<body>
<div id="numDiv">0</div>
<button id="start">start</button>
<button id="stop">stop</button>
</body>
</html>
index.js:
/** * Created by wwtliu on 14/8/16. */
var numDiv;
var work = null;
window.onload = function(){
numDiv = document.getElementById("numDiv");
document.getElementById("start").onclick = startWorker;
document.getElementById("stop").onclick = function(){
if(work){
work.terminate();
work = null;
}
}
}
function startWorker(){
if(work){
return;
}
work = new Worker("count.js");
work.onmessage = function(e){
numDiv.innerHTML = e.data;
}
}
count.js:
/** * Created by wwtliu on 14/8/16. */
var countNum = 0;
function count(){
postMessage(countNum);
countNum++;
setTimeout(count,1000);
}
count();