Here are some changes to improve the development workflow. In particular this change makes it easier to update the wasm app code, and virtually eliminates the need to reload the service worker (but makes it easy to reload that too).
This is inspired by #2, but takes a different approach to refreshing.
Changes:
Automatically check for and update the WASM App code without reloading the service worker
Check for update when a client page refreshes to mimic expected web refreshing behavior
Uses Etags to determine if the WASM App instance should be re-initialized and replaced on update
Prevent multiple simultaneous requests to update
Check for new app code on a ~10m interval
Before WASM App loads and while new versions of the App are downloading, the service worker passes all requests to the backend server.
Service worker should very rarely change, if ever, so if a SW update is found then transition immediately. This greatly simplifies update logic, and it should be fine to fallback to the origin server in the meantime.
Expose stop() function from WASM App to allow for shutdown activity. The WASM App should still tolerate being destroyed at any time.
Change service worker scope so it targets the whole origin, so a single wasm app serves all tabs on that origin
Add example counter to the returned html to show the shared state
Here are some changes to improve the development workflow. In particular this change makes it easier to update the wasm app code, and virtually eliminates the need to reload the service worker (but makes it easy to reload that too).
This is inspired by #2, but takes a different approach to refreshing.
Changes: