-
-
Save simonw/3ccba6256e95b59ea6a17509855830b4 to your computer and use it in GitHub Desktop.
This file contains 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 getTotalCacheSize() { | |
const cacheNames = await window.caches.keys(); | |
let totalSize = 0; | |
for (const cacheName of cacheNames) { | |
const cache = await window.caches.open(cacheName); | |
const keys = await cache.keys(); | |
for (const request of keys) { | |
const response = await cache.match(request); | |
const blob = await response.blob(); | |
totalSize += blob.size; | |
} | |
} | |
return (totalSize / (1024 * 1024)).toFixed(2) + ' MB'; | |
} | |
// Usage | |
getTotalCacheSize().then(size => console.log('Total cache size:', size)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Run in Chrome to see the total cache size used by the current page. I ran this on https://huggingface.co/spaces/reach-vb/github-issue-generator-webgpu and got 924.80MB.