Clear old caches

old-stable24
Varun Patil 2022-10-16 19:17:56 -07:00
parent db2dc38b78
commit de4bb84e40
1 changed files with 7 additions and 0 deletions

View File

@ -170,6 +170,13 @@ let staticCache: Cache | null = null;
const cacheName = `memories-${loadState('memories', 'version')}-${getCurrentUser()!.uid}`;
openCache().then((cache) => { staticCache = cache });
// Clear all caches except the current one
caches.keys().then((keys) => {
keys.filter((key) => key.startsWith('memories-') && key !== cacheName).forEach((key) => {
caches.delete(key);
});
});;
/** Open the cache */
export async function openCache() {
return await caches.open(cacheName);