After a deployment, users with open tabs still have old JavaScript bundles. When they navigate, dynamic imports reference chunk URLs that no longer exist on the server, causing 404s, broken UI, or blank pages.
One has built-in skew protection that detects these failures and recovers automatically.
vite.config.ts
With skewProtection: true (the default), One detects chunk load failures and automatically reloads the page. This covers two failure paths:
vite:preloadError event when Vite’s module preloader fails to fetch a chunkdynamicImport() calls fail with browser-specific chunk load error messages (Chrome, Firefox, Safari)When a failure is detected, the page reloads so the browser fetches fresh HTML with the new asset URLs. A sessionStorage guard prevents infinite reload loops — if a reload already happened within the last 10 seconds, the guard stops further reloads.
No configuration needed. This is always on unless you explicitly set skewProtection: false.
vite.config.ts
Proactive mode adds version polling on top of error recovery. Instead of waiting for a chunk to fail, the client periodically checks whether a new version has been deployed and forces a full-page navigation on the next link click.
version.json file containing the build’s cache keyversion.json every 2 minutes with cache-busting headerswindow.location.href navigation so the server returns fresh HTML with new assetsThis is similar to how SvelteKit handles version skew. The user never sees a broken page — they just get a slightly slower (full-page) navigation that loads the new deployment.
When a version mismatch is detected, One dispatches a one-version-update custom event on window:
You can use this to show users a “new version available” banner with a manual refresh button instead of waiting for the next navigation.
The window.__oneVersionStale flag is set to true when a version mismatch is detected. You can check this from anywhere in your app:
To turn off skew protection entirely:
vite.config.ts
This disables both the error recovery reload and the proactive polling. Chunk load failures will be silently swallowed as they were before this feature existed.
With skew protection enabled, One automatically sets cache headers that allow CDN edge caching for SSG and SPA pages:
Terminal
This means:
no-cache since content is dynamic per requestPreviously, CDN caching HTML was risky: after a deploy, cached HTML references old JS bundles that may not exist, causing 404s and broken pages.
Skew protection solves this. If a cached page tries to load a missing chunk:
vite:preloadErrorThe worst case is a brief flash on reload — much better than a broken page.
If you need custom cache behavior, set headers in your loader or middleware:
Custom headers take precedence — One only sets defaults when no cache-control header is present.
Edit this page on GitHub.