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();
  • 相关阅读:
    二分法查找递归方式()
    JDBC操作MySQL(crud)
    (转)JAVA中的权限修饰符
    抽象类和接口(面试题总结)
    java基础-集合
    Java泛型通配符以及限定
    div中嵌套的多个div使用了浮动后居中的办法
    将博客搬至CSDN
    (补)Java解析XML之dom4j
    Java单元测试
  • 原文地址:https://www.cnblogs.com/zjunet/p/4559875.html
Copyright © 2011-2022 走看看