本地缓存(快速加载)--menifest之应用

来源:互联网 发布:office办公软件绿色版 编辑:程序博客网 时间:2024/06/04 08:25

html5引入的应用程序缓存(Application Cache),通过创建manifest文件就可以创建web离线应用版本,把资源下载到本地,可以实现快速加载,在没有网络资源情况下也可以浏览资源,还可以减少服务器的负载,

应用manifest文件:

<html manifest = "demo.manifest">

Manifest文件的基本格式   CACHE MANIFEST为文件的声明

CACHE  需要缓存的文件

实例:

    CACHE MANIFEST
    CACHE
    // 缓存theme.css和main.js这两个文件
            /theme.css
    /main.js


NETWORK – 不被缓存的文件





CACHE MANIFEST
NETWORK:
//    不缓存login.php,*表示全部
login.php


FALLBACK – 制定无法访问文件时的文件





CACHE MANIFEST
FALLBACK:
#当无法访问index.js时,访问main.js
/index.js /main.js

完整的 Manifest 文件











CACHE MANIFEST
# 2016-04-21 v1.0
/theme.css
/main.js

NETWORK:
login.php

FALLBACK:
/index.js /main.js





更新缓存
1.修改manifest文件
2.通过js清除缓存,window.applicationCache.update();
3.清除浏览器缓存




0 0
原创粉丝点击