// static/sw.js — Odysseus PWA Service Worker // Strategy: // - HTML (navigation): stale-while-revalidate. Instant open from cache, // background refresh so the next open has latest HTML. // - JS/CSS (/static/*.js|.css): network-first, cache fallback for offline. // (So code/style edits show up on a normal reload, no manual cache clear.) // - Other static assets (images/fonts/libs): cache-first with bg refresh. // - API / non-GET: never cached. // Bump CACHE_NAME whenever the precache list or SW logic changes. const CACHE_NAME = 'odysseus-v380-shared-config-image-editor-lazy-katex-mermaid'; // KaTeX resolves these from its own stylesheet, so caching the CSS without them // gives offline math fallback glyphs instead of proper typesetting. const KATEX_FONTS = [ 'AMS-Regular', 'Caligraphic-Bold', 'Caligraphic-Regular', 'Fraktur-Bold', 'Fraktur-Regular', 'Main-Bold', 'Main-BoldItalic', 'Main-Italic', 'Main-Regular', 'Math-BoldItalic', 'Math-Italic', 'SansSerif-Bold', 'SansSerif-Italic', 'SansSerif-Regular', 'Script-Regular', 'Size1-Regular', 'Size2-Regular', 'Size3-Regular', 'Size4-Regular', 'Typewriter-Regular', ].map(name => `/static/lib/katex/fonts/KaTeX_${name}.woff2`); // Two lists, two jobs — they are no longer the same set and must not be // "resynced" back into one: // // PRECACHE = the app shell. Mirrors the