yew-pwa-minimal icon indicating copy to clipboard operation
yew-pwa-minimal copied to clipboard

Fix caching in the service worker

Open fkohlgrueber opened this issue 2 years ago • 2 comments

After switching to trunk, the filenames of the wasm module and the generated js file contain a hash and will change on every update.

Currently, the service_worker.js file contains a list of filenames to cache, which doesn't work anymore due to the hash being part of the filename.

Possible solutions:

  • Tell trunk to generate stable filenames without hashes
  • Generate / modify service_worker.js during build such that it contains the correct filenames

I don't know much about web dev and caching in particular, so it's not clear to me which option is preferable. I'll leave this issue open for now, but feel free to make suggestions on the topic.

fkohlgrueber avatar Jul 11 '22 08:07 fkohlgrueber

I don't have enough time to open a PR but for everyone looking for fix - you can add

[build]
filehash = false

to Trunk.toml to tell trunk to generate stable filenames

damszew avatar Nov 25 '22 06:11 damszew

#6 implements @damszew's solution.

Is this all we need to do? Does this have any impact on cache invalidation? Do we have a strategy in that space?

0awful avatar Jan 11 '23 04:01 0awful