UNPKG

457 BJavaScriptView Raw
1/*
2 * Deletes all caches that start with the `prefix`, except for the
3 * cache defined by `currentCache`
4 */
5export default (prefix, currentCache) => {
6 return caches.keys().then((cacheNames) => {
7 cacheNames.forEach((cacheName) => {
8 let isOwnCache = cacheName.indexOf(prefix) === 0;
9 let isNotCurrentCache = cacheName !== currentCache;
10
11 if (isOwnCache && isNotCurrentCache) {
12 caches.delete(cacheName);
13 }
14 });
15 });
16};