diff options
Diffstat (limited to 'js/index.js')
-rw-r--r-- | js/index.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/js/index.js b/js/index.js index c5f8926..336232f 100644 --- a/js/index.js +++ b/js/index.js @@ -1,3 +1,18 @@ +function cache_refresh() { + if ('serviceWorker' in navigator) { + localforage.getItem("epube-cache.timestamp").then(function(stamp) { + var ts = parseInt(new Date().getTime()/1000); + + if (!stamp || ts - stamp > 3600) { + console.log('asking worker to refresh cache'); + navigator.serviceWorker.controller.postMessage("refresh-cache"); + localforage.setItem("epube-cache.timestamp", ts); + } + + }); + } +} + function mark_offline(elem) { var bookId = elem.getAttribute("data-book-id"); |