import { InjectionToken } from '@angular/core'; import { DynamicCaches } from './dynamic-cache'; export const APP_LEVEL_CACHE = 'app-level-cache'; export const DYNAMIC_CACHES = new InjectionToken('dynamic-caches'); export async function wipeAllCaches() { console.log('get caches keys'); const keys = await caches.keys(); for (const cache of keys) { await wipeCache(cache); } } export function wipeCache(cacheName: string) { console.log('delete cache: ', cacheName); return caches.delete(cacheName); } export async function wipeCacheEntry(cacheName: string, entry: string) { console.log('open cache: ', cacheName); const cache = await caches.open(cacheName); return cache.delete(entry, { ignoreSearch: false }); }