I have a site with a service worker with multiple caches, which have files used for different reasons. I'd to be able to clear (or delete) one particular cache from my program on demand, not from within the service worker itself. This is what I've tried:
async function clearCache(cacheName) {
if ('caches' in window) {
return await caches.delete(cacheName);
}
}
I can get the cache from the window object, but can't seem to delete it. I've also tried looping through the cache and deleting all the files individually, but that didn't work either.
Is this possible?