zoukankan      html  css  js  c++  java
  • 页面缓存处理技巧

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

    <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();
  • 相关阅读:
    bzoj 1057: [ZJOI2007]棋盘制作
    【NOIP2012】开车旅行
    bzoj 2326: [HNOI2011]数学作业
    一本通1527欧拉回路
    一本通1530 Ant Trip
    一本通1528单词游戏
    luogu1856
    CF1045G
    10.18模拟赛
    10.16模拟赛
  • 原文地址:https://www.cnblogs.com/zjunet/p/4559875.html
Copyright © 2011-2022 走看看