Mercurial
comparison mrjunejune/src/public/sw.js @ 242:543df0fe7168
[tools] Add full HLS player support
| author | MrJuneJune <me@mrjunejune.com> |
|---|---|
| date | Mon, 03 Aug 2026 13:14:41 -0700 |
| parents | 9c2eec61a152 |
| children |
comparison
equal
deleted
inserted
replaced
| 241:9c2eec61a152 | 242:543df0fe7168 |
|---|---|
| 1 // Service Worker for MrJuneJune PWA | 1 // Service Worker for MrJuneJune PWA |
| 2 const CACHE_VERSION = 'v2-webp'; | 2 const CACHE_VERSION = 'v4-hlsjs'; |
| 3 const CACHE_NAME = `mrjunejune-${CACHE_VERSION}`; | 3 const CACHE_NAME = `mrjunejune-${CACHE_VERSION}`; |
| 4 | 4 |
| 5 // Files to cache immediately on install | 5 // Files to cache immediately on install |
| 6 const STATIC_CACHE = [ | 6 const STATIC_CACHE = [ |
| 7 '/', | 7 '/', |
| 67 // Skip API calls and media uploads (always go to network) | 67 // Skip API calls and media uploads (always go to network) |
| 68 if (url.pathname.startsWith('/api/')) { | 68 if (url.pathname.startsWith('/api/')) { |
| 69 return; | 69 return; |
| 70 } | 70 } |
| 71 | 71 |
| 72 // The HLS tool and media must always reflect the current player version. | |
| 73 if (url.pathname.startsWith('/tools/hls_player') || | |
| 74 url.pathname.startsWith('/public/hls-sample/')) { | |
| 75 return; | |
| 76 } | |
| 77 | |
| 72 event.respondWith( | 78 event.respondWith( |
| 73 caches.match(request).then((cachedResponse) => { | 79 caches.match(request).then((cachedResponse) => { |
| 74 if (cachedResponse) { | 80 if (cachedResponse) { |
| 75 console.log('[SW] Serving from cache:', url.pathname); | 81 console.log('[SW] Serving from cache:', url.pathname); |
| 76 return cachedResponse; | 82 return cachedResponse; |