Changeset df9da7d in Klonkt
- Timestamp:
- 07/16/2026 12:20:51 PM (8 weeks ago)
- Branches:
- main
- Children:
- 72f936a
- Parents:
- 4424af7
- git-author:
- Robin <roboburr@…> (07/12/2026 11:35:56 PM)
- git-committer:
- Robin <roboburr@…> (07/16/2026 12:20:51 PM)
- File:
-
- 1 edited
-
src/server.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/server.js
r4424af7 rdf9da7d 470 470 res.set('Cache-Control', 'no-cache'); 471 471 res.send(` 472 const CACHE_VERSION = 'pcms-v1 6-' + new Date().toISOString().split('T')[0];472 const CACHE_VERSION = 'pcms-v17-' + new Date().toISOString().split('T')[0]; 473 473 self.addEventListener('install', e => { 474 474 e.waitUntil(caches.open(CACHE_VERSION).then(c => c.addAll(['/']))); … … 495 495 try { if (new URL(e.request.url).origin !== self.location.origin) return; } catch (err) { return; } 496 496 e.respondWith( 497 fetch(e.request).catch(() => caches.match('/').then(r => r || Response.error())) 497 fetch(e.request).then(resp => { 498 // Network-first: always serve fresh when online. Also refresh the '/' offline 499 // fallback with the homepage we just served, so a later cold start on a flaky or 500 // offline connection no longer shows the stale install-time snapshot ("old data 501 // on first PWA load"). 502 try { 503 if (resp && resp.ok && new URL(e.request.url).pathname === '/') { 504 const copy = resp.clone(); 505 e.waitUntil(caches.open(CACHE_VERSION).then(c => c.put('/', copy)).catch(() => {})); 506 } 507 } catch (err) { /* ignore cache refresh failures */ } 508 return resp; 509 }).catch(() => caches.match('/').then(r => r || Response.error())) 498 510 ); 499 511 });
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)