如果不让浏览器对页面进行缓存,可以加这么几行代码:

<HEAD>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="0">
</HEAD>

php做法:

<?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 manifest="index.appcache">

然后在响应的文件:

CACHE MANIFEST

CACHE:
webhuancun.php


NETWORK:
style.css3

这里写图片描述

webworker:
多线程处理,可以让另外一个js文件来处理一些东西,然后返回主js文件,看下面的图:
这里写图片描述

然后我们可以记录一下三个文件的写法,注意这只是一个小例子:

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();
posted on 2015-06-03 15:39  虽然如此  阅读(291)  评论(0编辑  收藏  举报