this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Try this solution to clean up excess SW cache

+24
+24
src/main.jsx
··· 48 48 } catch (e) {} 49 49 }, 5000); 50 50 51 + // Service worker cache cleanup 52 + if ('serviceWorker' in navigator && typeof caches !== 'undefined') { 53 + const MAX_SW_CACHE_SIZE = 300; 54 + let swInterval = setInterval(() => { 55 + if (window.__IDLE__) { 56 + clearInterval(swInterval); 57 + (async () => { 58 + const keys = await caches.keys(); 59 + for (const key of keys) { 60 + const cache = await caches.open(key); 61 + const _keys = await cache.keys(); 62 + if (_keys.length > MAX_SW_CACHE_SIZE) { 63 + console.warn('Cleaning cache', key, _keys.length); 64 + const deleteKeys = _keys.slice(MAX_SW_CACHE_SIZE); 65 + for (const deleteKey of deleteKeys) { 66 + await cache.delete(deleteKey); 67 + } 68 + } 69 + } 70 + })(); 71 + } 72 + }, 15_000); 73 + } 74 + 51 75 window.__CLOAK__ = () => { 52 76 document.body.classList.toggle('cloak'); 53 77 };