From 01624c6efa865a3744a5594d50cc693305e51836 Mon Sep 17 00:00:00 2001 From: agent Date: Sun, 27 Sep 2026 10:17:21 +0000 Subject: [PATCH] Bypass the HTTP cache when the service worker caches assets Hashed assets are served as immutable for a year. Before the nginx MIME fix, the pdf.js worker was served as application/octet-stream, and the browser kept that response. Each new service worker then copied it from the HTTP cache into its offline cache, so PDFs still failed to render after the server was fixed. Fetching with cache: 'reload' always takes the current response from the server. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01VsorPV3JeJRoZ1mD1pdvtL --- src/service-worker.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/service-worker.ts b/src/service-worker.ts index 0927424..61757f3 100644 --- a/src/service-worker.ts +++ b/src/service-worker.ts @@ -16,7 +16,9 @@ sw.addEventListener('install', (event) => { event.waitUntil( caches .open(CACHE) - .then((c) => c.addAll(ASSETS)) + // Bypass the HTTP cache: hashed assets are cached as immutable, so a bad + // response (e.g. a wrong MIME type) would otherwise be copied in forever. + .then((c) => c.addAll(ASSETS.map((url) => new Request(url, { cache: 'reload' })))) .then(() => sw.skipWaiting()) ); }); -- 2.51.2