Created
March 11, 2018 21:41
-
-
Save ritikrishu/d4990dade15966894c744158dcf415c7 to your computer and use it in GitHub Desktop.
delete previous version static caches from CacheStorage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
suppose, static caches are categorized as static-imgs-v1, static-js-v1... | |
*/ | |
const version = 'v2'; | |
const staticPrefix = 'static-' | |
caches.keys().then(function (cacheNames) { | |
return Promise.all( | |
cacheNames.filter(function (cacheName) { | |
return cacheName.startsWith(staticPrefix) && | |
!cacheName.endsWith(version); | |
}).map(function (cacheName) { | |
return caches.delete(cacheName); | |
}) | |
); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment