export const APP_LEVEL_CACHE = 'app-level-cache'; export const DYNAMIC_CACHES = [ { urls: ['/assets/icons', '/assets/wv-resources'], name: 'cached-assets', clearOnLogout: false, maxAge: 24 * 3600, maxSize: 1000, methods: ['GET'] }, { urls: ['/download/original'], name: 'files', maxAge: 3600 * 24 * 7, maxSize: 1000, clearOnLogout: true, methods: ['GET'] } ]; export async function wipeCaches(logoutDependant: boolean = false) { await caches.delete(APP_LEVEL_CACHE); for (const cache of DYNAMIC_CACHES) { if (!logoutDependant) { caches.delete(cache.name); } if (logoutDependant && cache.clearOnLogout) { caches.delete(cache.name); } } } export async function wipeCacheEntry(cacheName: string, entry: string) { caches.open(cacheName).then(cache => { cache.delete(entry, { ignoreSearch: false }); }); }