From 778b06584042b8c121ff5d975f262e19d6bd2565 Mon Sep 17 00:00:00 2001 From: David Waring Date: Sun, 20 Dec 2020 11:59:10 -0500 Subject: [PATCH] Cache: clear includes SW caches --- src/utils/cache.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/utils/cache.js b/src/utils/cache.js index 99c5b4a..d05046d 100644 --- a/src/utils/cache.js +++ b/src/utils/cache.js @@ -485,13 +485,16 @@ function _putCache(path, response, callback) { /** - * Clear all cached data + * Clear all cached data (including service worker caches) * @param {Function} [callback] Callback function(success) */ function clear(callback) { - caches.delete(API_CACHE).then(function(success) { - console.log("CACHE DELETED: " + success); - if ( callback ) return callback(success); + caches.keys().then(cacheNames => { + cacheNames.forEach(cacheName => { + console.log("...deleting cache: " + cacheName); + caches.delete(cacheName); + }); + if ( callback ) return callback(true); }); }