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 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VsorPV3JeJRoZ1mD1pdvtL
This commit is contained in:
parent
cb4d3bfc79
commit
01624c6efa
1 changed files with 3 additions and 1 deletions
|
|
@ -16,7 +16,9 @@ sw.addEventListener('install', (event) => {
|
||||||
event.waitUntil(
|
event.waitUntil(
|
||||||
caches
|
caches
|
||||||
.open(CACHE)
|
.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())
|
.then(() => sw.skipWaiting())
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue