Demo: disable the JupyterLite service worker so redeploys show on reload
The service worker is an offline caching proxy for the app and content
files, so it kept serving stale notebooks after a redeploy even with
in-memory storage. The numbl kernel doesn't need it (it reads content on
the main thread, not via the SW kernel drive), so disable the
service-worker-manager plugin. Combined with memory storage, reloads now
re-seed the latest deployed content.
2 changed files+24−8
README.mdmodified+20−7View file
@@ -61,11 +61,19 @@ deploys it to GitHub Pages.
6161
6262 ### Always-fresh content (demo choice)
6363
64-By default JupyterLite copies notebooks into the browser's IndexedDB on
65-first visit, and that local copy then wins over the deployed files **even
66-after a redeploy** — so returning visitors keep seeing stale content. Since
67-this is a demo, `demo/jupyter-lite.json` opts into JupyterLite's in-memory
68-storage so every page reload re-seeds the latest deployed notebooks:
64+JupyterLite caches content in two layers that both defeat redeploys:
65+
66+1. It copies notebooks into the browser's IndexedDB on first visit, and that
67+ local copy then wins over the deployed files **even after a redeploy**.
68+2. Its **service worker** is an offline caching proxy for the app itself and
69+ for content files, so it can keep serving the old app and old notebooks
70+ after a redeploy until it happens to update.
71+
72+Since this is a demo, `demo/jupyter-lite.json` neutralizes both: it uses
73+JupyterLite's in-memory storage (so every reload re-seeds the latest
74+deployed notebooks) and disables the service-worker plugin (which the numbl
75+kernel doesn't need — it reads content on the main thread, not via the
76+service worker's kernel drive):
6977
7078 ```json
7179 {
@@ -73,13 +81,18 @@ storage so every page reload re-seeds the latest deployed notebooks:
7381 "enableMemoryStorage": true,
7482 "contentsStorageDrivers": ["memoryStorageDriver"],
7583 "settingsStorageDrivers": ["memoryStorageDriver"],
76- "workspacesStorageDrivers": ["memoryStorageDriver"]
84+ "workspacesStorageDrivers": ["memoryStorageDriver"],
85+ "disabledExtensions": [
86+ "@jupyterlite/application-extension:service-worker-manager"
87+ ]
7788 }
7889 }
7990 ```
8091
8192 The trade-off is that a visitor's edits live only for the session and are
82-discarded on reload. For a real deployment where users should keep their
93+discarded on reload. A visitor who loaded the site **before** the service
94+worker was disabled still has it registered and must clear browser data
95+(or `Help > Clear Browser Data`) once to get past it. For a real deployment where users should keep their
8396 work, omit these keys (the default persistent storage) and bump
8497 `contentsStorageName` when you want to force-refresh shipped content.
8598 numbl's own package cache (installed via `mip`) lives in a separate
demo/jupyter-lite.jsonmodified+4−1View file
@@ -6,6 +6,9 @@
66 "enableMemoryStorage": true,
77 "contentsStorageDrivers": ["memoryStorageDriver"],
88 "settingsStorageDrivers": ["memoryStorageDriver"],
9- "workspacesStorageDrivers": ["memoryStorageDriver"]
9+ "workspacesStorageDrivers": ["memoryStorageDriver"],
10+ "disabledExtensions": [
11+ "@jupyterlite/application-extension:service-worker-manager"
12+ ]
1013 }
1114 }