cacheUsage.html (752B)
1 <html> 2 <head> 3 <script> 4 async function getStorageEstimate() { 5 let r = await navigator.storage.estimate(); 6 return r.usage; 7 } 8 9 function openCache(id) { 10 return caches.open(id); 11 } 12 13 async function doCacheWork(id, n) { 14 let c = await openCache(id); 15 16 const body = new Uint32Array(1024); 17 self.crypto.getRandomValues(body); 18 19 for (let i = 0; i < n; i++) { 20 await c.put(new Request(`/data-${i}`), new Response(body)) 21 } 22 23 await caches.delete(id) 24 return "success"; 25 } 26 </script> 27 </head> 28 </html>