this repo has no description
0
fork

Configure Feed

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

Double-down on reducing cache size

+18 -18
+18 -18
src/main.jsx
··· 50 50 51 51 // Service worker cache cleanup 52 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 - } 53 + const MAX_SW_CACHE_SIZE = 30; 54 + const IGNORE_CACHE_KEYS = ['icons']; 55 + const clearCaches = async () => { 56 + if (!window.__IDLE__) return; 57 + const keys = await caches.keys(); 58 + for (const key of keys) { 59 + if (IGNORE_CACHE_KEYS.includes(key)) continue; 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); 69 67 } 70 - })(); 68 + } 71 69 } 72 - }, 15_000); 70 + }; 71 + setTimeout(clearCaches, 10_000); // after 10 seconds 72 + setInterval(clearCaches, 30 * 60 * 1000); // every 30 minutes 73 73 } 74 74 75 75 window.__CLOAK__ = () => {