From c5efd7c3e7f2f1b88f1bc22c207b5efaa344928c Mon Sep 17 00:00:00 2001 From: Skylar Ittner Date: Wed, 8 Jan 2020 14:58:34 -0700 Subject: [PATCH] Don't cache app assets on Cordova or NW.js platforms --- www/cache.js | 19 ++++++++++++++----- www/index.html | 4 +++- www/settings.js | 2 +- www/sw.js | 32 ++++++++++++++++++-------------- 4 files changed, 36 insertions(+), 21 deletions(-) diff --git a/www/cache.js b/www/cache.js index 812062c..29760a0 100644 --- a/www/cache.js +++ b/www/cache.js @@ -126,6 +126,8 @@ for (i in SETTINGS.weathericons) { cachedurls.push("assets/images/weather-" + SETTINGS.weathericons[i] + ".svg"); } +var cacheFilled = false; + function fillCache(cachename) { if ('caches' in window) { // delete old caches @@ -137,15 +139,22 @@ function fillCache(cachename) { })); }); + cacheFilled = true; // assume good caches.open(cachename).then(function (cache) { for (i in cachedurls) { - cache.add(cachedurls[i]); + try { + cache.add(cachedurls[i]); + } catch (ex) { + cacheFilled = false; + } } }); - // Do it again in a little while to reduce chance of errors - setTimeout(function () { - fillCache(cachename); - }, 1000 * 30); + // Do it again in a little while + if (!cacheFilled) { + setTimeout(function () { + fillCache(cachename); + }, 1000 * 30); + } } } \ No newline at end of file diff --git a/www/index.html b/www/index.html index 210dfd8..0ef2e31 100644 --- a/www/index.html +++ b/www/index.html @@ -69,7 +69,9 @@