This repository was archived by the owner on Jan 11, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 420
SW not serving precached files #1210
Copy link
Copy link
Closed
Labels
Description
Describe the bug
The serviceworker does not serve cached files because of a missing "/" in the filenames of the cached
-variable
To Reproduce
Run npx degit "sveltejs/sapper-template#rollup" my-app
and set a breakpoint in the serviceworker.
Expected behavior
The serviceworker should find the cached files and return them.
Information about your Sapper Installation:
-
Your browser and the version: Chromium Version 81.0.4044.138 (Developer Build) (64-bit)
-
Your operating system: Voidlinux Kernel 5.4.40_1
-
Sapper version 0.27.13
-
Svelte version 3.22.3
-
Whether your application uses Webpack or Rollup: Happens with both templates.
Severity
annoying
Workaround
My current workaround is to prepend a "/" for the filenames in the cached
variable:
// `shell` is an array of all the files generated by the bundler,
// `files` is an array of everything in the `static` directory
const to_cache = shell.concat(files);
//const cached = new Set(to_cache);
const cached = new Set(to_cache.map(filename => `/${filename}`));