Skip to content

Commit

Permalink
Cache: clear includes SW caches
Browse files Browse the repository at this point in the history
  • Loading branch information
dwaring87 committed Dec 20, 2020
1 parent 8208bc2 commit 778b065
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/utils/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}

Expand Down

0 comments on commit 778b065

Please # to comment.