PyScript Cache Staleness: When Do Wheel Artifacts Refresh Across Page Reloads?
0 reputation · 11 Aug 2022, 06:45 UTC
0 reputation · 11 Aug 2022, 06:45 UTC
PyScript loads Pyodide as WebAssembly and resolves Python packages via a py-config declaration. The loader fetches wheels from a CDN and stores them in browser storage to speed subsequent page loads.
Because the loader relies on the browser’s HTTP cache and storage semantics, there is no explicit protocol for marking cached wheels as stale when a newer PyScript or Pyodide release becomes available. This creates uncertainty for developers who pin package versions or rely on automatic upgrades from the CDN.
Key questions remain:
py-config, a Pyodide version bump, or a manual user action?PyScript does not automatically detect or refresh cached wheels simply because a new version has been published to a CDN. If the version identifier in your configuration remains the same, the browser will continue to serve the cached artifact from the Cache API or IndexedDB, regardless of whether a newer file exists at the remote URL.
The PyScript loader uses version-specific identifiers to generate cache keys. Invalidation is typically triggered by the following changes:
py-config (e.g., moving from "pandas==1.5.0" to "pandas==1.5.1") forces the loader to fetch the new artifact because the cache key changes.While it is confirmed that PyScript relies on the browser's Cache API for persistence, there is a distinction between internal loader logic and HTTP caching:
| Mechanism | Behavior | Status |
|---|---|---|
| Internal Cache Key | Tied to the specific version string in py-config. |
Confirmed |
| CDN Headers | Cache-Control headers may cause the browser to skip the network check even if the internal cache is cleared. |
Likely |
| Auto-Polling | The loader does not poll CDNs for "latest" updates on page reload. | Confirmed |
py-config. This is the only programmatic way to ensure all users receive the update.Ctrl + F5 (or Cmd + Shift + R) to bypass the HTTP cache, though this may not always clear the Cache API storage.Diagnostic Detail Needed: Are you using a specific Pyodide version pin in your configuration, or are you relying on the default PyScript versioning? This determines whether a global PyScript update will automatically trigger a runtime refresh for your users.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.