appcache checking update

<!DOCTYPE html>
<html manifest="a.appcache">
<head>
    <title></title>
</head>
<body>
1aaaa
<script>
    function onAppCacheReady() {
        appCache.swapCache();
        localStorage.clear();
        window.location.reload();
    }
    function onAppCacheIdle() {
    }
    var appCache = window.applicationCache;


    if (appCache.status == appCache.UPDATEREADY) {//have update

        onAppCacheReady();
    }
    else if (appCache.status == appCache.CHECKING || appCache.status == appCache.DOWNLOADING) {
        appCache.onupdateready = onAppCacheReady;
        appCache.onnoupdate = appCache.onobsolete = function () {
            onAppCacheIdle();
        };
    }


</script>
</body>
</html>

a.appcache:

CACHE MANIFEST
# 9891a09e51adaasdasd
asd.html


FALLBACK:


NETWORK:
*

  

When the a.appcache file is changed,then appCache.status will be changed; 

posted @ 2013-10-13 23:07  高捍得  阅读(448)  评论(0编辑  收藏  举报