Skip to content

Instantly share code, notes, and snippets.

@Ivannnnn
Created September 11, 2022 16:04
Show Gist options
  • Save Ivannnnn/11c9f41bfc548bbaecc536c71d0930a2 to your computer and use it in GitHub Desktop.
Save Ivannnnn/11c9f41bfc548bbaecc536c71d0930a2 to your computer and use it in GitHub Desktop.
const getCacheAll = async (name, q) => {
const cache = await caches.open(name);
return cache.matchAll(q);
};
const logText = (matches) =>
Promise.all(matches.map((r) => r.text().then((txt) => [r.url, txt])));
async function clearCache(name) {
const cache = await caches.open(name);
const matches = await cache.matchAll();
return Promise.all(matches.map((match) => cache.delete(match.url)));
}
//
(async () => {
//await clearCache('job-tracker')
const result = await logText(await getCacheAll("job-tracker"));
console.log(result);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment