fix: prevent service worker from caching stale HTML#1060
Merged
Conversation
- Increase polling intervals (markets 8→12min, feeds 15→20min, crypto 8→12min) - Increase background tab hiddenMultiplier from 10→30 (polls 3x less when hidden) - Double CDN s-maxage TTLs across all cache tiers in gateway - Add CDN-Cache-Control header for Cloudflare-specific longer edge caching - Add ETag generation + 304 Not Modified support in gateway (zero-byte revalidation) - Add CDN-Cache-Control to bootstrap endpoint - Add explicit SPA rewrite rule in vercel.json for CF proxy compatibility - Add Cache-Control headers for /map-styles/, /data/, /textures/ static paths
- vercel.json: apply no-cache headers to ALL SPA routes (same regex as rewrite rule), not just / and /index.html — prevents CF proxy from caching stale HTML that references old content-hashed bundle filenames - Polymarket: add server-side aggregation via Railway seed script that fetches all tags once and writes to Redis, eliminating 11-request fan-out per user per poll cycle - Bootstrap: add predictions to hydration keys for zero-cost page load - RPC handler: read Railway-seeded bootstrap key before falling back to live Gamma API fetch - Client: 3-strategy waterfall (bootstrap → RPC → fan-out fallback)
- Change navigation handler from NetworkFirst (3s timeout) to NetworkOnly so HTML always comes from the network, never from stale SW cache - Reduce SW update check interval from 60min to 5min so new deploys propagate to users faster - Root cause: SW precached all .js files, and NetworkFirst with 3s timeout would fall back to stale cached HTML referencing old content-hashed bundles that no longer exist after deploy → 404
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
4 tasks
koala73
added a commit
that referenced
this pull request
Mar 5, 2026
Users with stale service workers get 404s on content-hashed bundles. The deployed sw.js has skipWaiting+clientsClaim but old SWs from before PR #1060 don't self-update reliably. This adds a one-time nuke in main.ts that unregisters all SWs, clears all caches, and reloads. Guarded by localStorage key so it only fires once per browser. Safe to remove after 2026-03-20.
koala73
added a commit
that referenced
this pull request
Mar 5, 2026
Users with stale service workers get 404s on content-hashed bundles. The deployed sw.js has skipWaiting+clientsClaim but old SWs from before PR #1060 don't self-update reliably. This adds a one-time nuke in main.ts that unregisters all SWs, clears all caches, and reloads. Guarded by localStorage key so it only fires once per browser. Safe to remove after 2026-03-20.
koala73
added a commit
that referenced
this pull request
Mar 5, 2026
Users with stale service workers get 404s on content-hashed bundles. The deployed sw.js has skipWaiting+clientsClaim but old SWs from before PR #1060 don't self-update reliably. This adds a one-time nuke in main.ts that unregisters all SWs, clears all caches, and reloads. Guarded by localStorage key so it only fires once per browser. Safe to remove after 2026-03-20.
aldoyh
pushed a commit
to aldoyh/worldmonitor
that referenced
this pull request
Mar 6, 2026
* perf: reduce Vercel data transfer costs with CDN optimization - Increase polling intervals (markets 8→12min, feeds 15→20min, crypto 8→12min) - Increase background tab hiddenMultiplier from 10→30 (polls 3x less when hidden) - Double CDN s-maxage TTLs across all cache tiers in gateway - Add CDN-Cache-Control header for Cloudflare-specific longer edge caching - Add ETag generation + 304 Not Modified support in gateway (zero-byte revalidation) - Add CDN-Cache-Control to bootstrap endpoint - Add explicit SPA rewrite rule in vercel.json for CF proxy compatibility - Add Cache-Control headers for /map-styles/, /data/, /textures/ static paths * fix: prevent CF from caching SPA HTML + reduce Polymarket bandwidth 95% - vercel.json: apply no-cache headers to ALL SPA routes (same regex as rewrite rule), not just / and /index.html — prevents CF proxy from caching stale HTML that references old content-hashed bundle filenames - Polymarket: add server-side aggregation via Railway seed script that fetches all tags once and writes to Redis, eliminating 11-request fan-out per user per poll cycle - Bootstrap: add predictions to hydration keys for zero-cost page load - RPC handler: read Railway-seeded bootstrap key before falling back to live Gamma API fetch - Client: 3-strategy waterfall (bootstrap → RPC → fan-out fallback) * fix: prevent service worker from serving stale HTML after deploys - Change navigation handler from NetworkFirst (3s timeout) to NetworkOnly so HTML always comes from the network, never from stale SW cache - Reduce SW update check interval from 60min to 5min so new deploys propagate to users faster - Root cause: SW precached all .js files, and NetworkFirst with 3s timeout would fall back to stale cached HTML referencing old content-hashed bundles that no longer exist after deploy → 404
aldoyh
pushed a commit
to aldoyh/worldmonitor
that referenced
this pull request
Mar 6, 2026
Users with stale service workers get 404s on content-hashed bundles. The deployed sw.js has skipWaiting+clientsClaim but old SWs from before PR koala73#1060 don't self-update reliably. This adds a one-time nuke in main.ts that unregisters all SWs, clears all caches, and reloads. Guarded by localStorage key so it only fires once per browser. Safe to remove after 2026-03-20.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Users are getting 404 errors on bundle files after deploys because the service worker's
NetworkFirsthandler with a 3-second timeout falls back to stale cached HTML that references old content-hashed bundles.Changes
vite.config.ts: Change navigation handler fromNetworkFirst(3s timeout) →NetworkOnly— HTML always comes from networksrc/main.ts: Reduce SW update check from 60min → 5min for faster deploy propagationWhy this fixes it
The SW precaches all
.jsfiles viaglobPatterns. On deploy, new hashes are generated. Until the SW updates its manifest, it serves the old HTML which references old bundle hashes → 404.NetworkOnlyfor navigation ensures HTML is never served from SW cache.Test plan
navigateFallback: null)