Created
December 2, 2018 17:39
-
-
Save jeffposnick/14d84fed45713587866a34b689a51ecd to your computer and use it in GitHub Desktop.
Code to find all opaque responses currently cached, and return their URLs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function findOpaqueResponses() { | |
const cacheNames = await caches.keys(); | |
const urlsResultingInAnOpaqueResponse = []; | |
for (const cacheName of cacheNames) { | |
const cache = await caches.open(cacheName); | |
const requests = await cache.keys(); | |
for (const request of requests) { | |
const response = await cache.match(request); | |
if (response.status === 0) { | |
urlsResultingInAnOpaqueResponse.push(request.url); | |
} | |
} | |
} | |
return urlsResultingInAnOpaqueResponse; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment