lazy-loading done
Some checks failed
ci / site (push) Has been cancelled
publish-image / publish (push) Has been cancelled

This commit is contained in:
2026-02-10 15:59:03 -05:00
parent 7bd51837de
commit ac3de3e142
24 changed files with 923 additions and 16 deletions

View File

@@ -5,7 +5,7 @@
*/
// Bump this value on deploy to invalidate caches.
const CACHE_VERSION = "v1";
const CACHE_VERSION = "v2";
const CACHE_SHELL = `shell-${CACHE_VERSION}`;
const CACHE_PAGES = `pages-${CACHE_VERSION}`;
@@ -123,6 +123,25 @@ self.addEventListener("fetch", (event) => {
return;
}
// Network-first for global CSS to avoid serving stale styling after deploy.
// (The SW already caches styles, but network-first prevents a "stuck" old CSS experience.)
if (url.origin === self.location.origin && url.pathname === "/styles/global.css") {
event.respondWith(
(async () => {
try {
const fresh = await fetch(request);
await cachePutSafe(CACHE_SHELL, request, fresh.clone());
return fresh;
} catch {
const cached = await caches.match(request);
if (cached) return cached;
return fetch(request);
}
})(),
);
return;
}
// Stale-while-revalidate for styles/scripts/fonts from same-origin.
if (
url.origin === self.location.origin &&