diff options
author | Andrew Dolgov <[email protected]> | 2017-02-26 13:12:33 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2017-02-26 13:12:33 +0300 |
commit | e01f57a3d98943954372110dc75e8d731fbacc10 (patch) | |
tree | 2d57e3a2368984f03507f2650f0b94273dced625 /worker.js | |
parent | b8ae4b31c129031e89e4c7fb9801d6761513dd73 (diff) |
further offline improvements
Diffstat (limited to 'worker.js')
-rw-r--r-- | worker.js | 29 |
1 files changed, 5 insertions, 24 deletions
@@ -1,10 +1,13 @@ -var CACHE_NAME = 'epube-test'; +//importScripts('lib/localforage.min.js'); + +var CACHE_NAME = 'epube-v1'; self.addEventListener('activate', function(event) { event.waitUntil( caches.open(CACHE_NAME).then(function(cache) { var urls = [ 'read.html', + 'js/common.js', 'js/read.js', 'js/offline.js', 'css/read.css', @@ -35,8 +38,6 @@ this.addEventListener('fetch', function(event) { if (resp) return resp; - console.log(req.url); - if (req.url.match("read.html")) { return caches.match("read.html"); } @@ -46,27 +47,7 @@ this.addEventListener('fetch', function(event) { } } - return fetch(req) - .then(function(resp) { - - if (req.url.match(/(getlastread|getpagination|\.epub)/)) { - caches.open(CACHE_NAME).then(function(cache) { - cache.put(event.request, resp.clone()); - }); - } /*else { - caches.match(req.url).then(function(cached) { - if (cached) { - console.log('refreshing ' + req.url); - - caches.open(CACHE_NAME).then(function(cache) { - cache.put(event.request, resp.clone()); - }); - } - }); - } */ - - return resp.clone(); - }); + return fetch(req); }) ); }); |