offline navigations: cache fallback and current-build assets (4/10)#93626
Draft
feedthejim wants to merge 1 commit intofeedthejim/offline-navigations-service-workerfrom
Draft
Conversation
This was referenced May 8, 2026
Contributor
Failing test suitesCommit: 2cb2dd5 | About building and testing Next.js
Expand output● offlineNavigations deploy-safe runtime behavior › registers the service worker and serves current-build assets from Cache Storage
Expand output● offlineNavigations deploy-safe runtime behavior › registers the service worker and serves current-build assets from Cache Storage |
This was referenced May 8, 2026
19163ff to
ff6adf4
Compare
33c0b95 to
4001039
Compare
ff6adf4 to
a7a800c
Compare
4001039 to
829dcd8
Compare
a7a800c to
08e8b61
Compare
829dcd8 to
1284032
Compare
1284032 to
f85d95c
Compare
08e8b61 to
55a94f7
Compare
This was referenced May 8, 2026
This was referenced May 8, 2026
Contributor
Stats from current PR🔴 1 regression
📊 All Metrics📖 Metrics GlossaryDev Server Metrics:
Build Metrics:
Change Thresholds:
⚡ Dev Server
📦 Dev Server (Webpack) (Legacy)📦 Dev Server (Webpack)
⚡ Production Builds
📦 Production Builds (Webpack) (Legacy)📦 Production Builds (Webpack)
📦 Bundle SizesBundle Sizes⚡ TurbopackClient Main Bundles
Server Middleware
Build DetailsBuild Manifests
📦 WebpackClient Main Bundles
Polyfills
Pages
Server Edge SSR
Middleware
Build DetailsBuild Manifests
Build Cache
🔄 Shared (bundler-independent)Runtimes
📝 Changed Files (3 files)Files with changes:
View diffspages-api.ru..time.prod.jsDiff too large to display pages.runtime.prod.jsDiff too large to display server.runtime.prod.jsDiff too large to display 📎 Tarball URLCommit: cfe3cce |
f85d95c to
af1aeea
Compare
7a5e5e9 to
b7f8165
Compare
ea10d83 to
fe9e691
Compare
2de7db3 to
07b14fe
Compare
53e06ad to
7e1dae0
Compare
This was referenced May 10, 2026
3a6dc55 to
a7c6088
Compare
14ed755 to
5a91f11
Compare
a7c6088 to
26fc34b
Compare
5a91f11 to
cfe3cce
Compare
8ac906e to
75c9392
Compare
cfe3cce to
694e1d0
Compare
694e1d0 to
1732a28
Compare
75c9392 to
5b339ab
Compare
1732a28 to
2cb2dd5
Compare
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.
Stack Position
This is PR 4 of 10. It teaches the service worker to cache the fallback document, fallback bootstrap assets, and current-build framework static assets.
Review guide:
https://gist.github.com/feedthejim/a10f757cf07c5550f731adf2fcf1077b
Full Stack
offline navigations: add gated build primitives (1/10)offline navigations: generate fallback document artifacts (2/10)offline navigations: register pass-through worker (3/10)offline navigations: cache fallback and current-build assets (4/10)offline navigations: serve fallback document offline (5/10)offline navigations: add router-cache persistence primitives (6/10)offline navigations: persist cached router records (7/10)offline navigations: bootstrap fallback from router records (8/10)offline navigations: support dynamic route patterns (9/10)offline navigations: add docs and examples (10/10)What This Changes
This is the runtime caching slice. The service worker caches:
_next/staticassets that the page has already loaded or prefetched.The current-build asset handoff intentionally uses browser cache lookups with
cache: 'only-if-cached'andmode: 'same-origin', so the service worker does not duplicate network fetches and can preserve deployment query strings such as Vercel?dpl=....The generated caching worker source is split into compact concern-based fragments for URL normalization, deployment-query merging, required resource caching, static asset cache-key selection, current-asset promotion, and worker listeners. The emitted worker remains minified and size-budgeted.
This PR also adds a deploy-safe e2e fixture under
test/e2ethat observes the behavior through browser-visible APIs instead of reading.next.What Works After This PR
The fallback document and current-build static assets can be present in Cache Storage. The service worker still does not serve the fallback document for failed navigations.
What Does Not Work Yet
Offline document recovery starts in PR 5. Persisted router-cache replay starts in PR 8.
Reviewer Focus
Please focus on the division of responsibility: the service worker owns document survival and static asset survival only. It should not parse Flight payloads, store per-route RSC data, or decide route eligibility.
Proof in This PR
Runtime and deploy-safe asset caching are covered by:
HEADLESS=true pnpm test-start-turbo test/e2e/app-dir/offline-navigations-deploy/offline-navigations-deploy.test.tsHEADLESS=true pnpm test-start-turbo test/production/app-dir/offline-navigations/offline-navigations.test.tsHEADLESS=true pnpm test-start-webpack test/production/app-dir/offline-navigations/offline-navigations.test.tsThe production suite also asserts that the emitted worker contains the expected message types, avoids comments and accidental whitespace, and stays under its byte budget. True deploy-mode proof is still pending CI or a custom deploy run. A local
test-deploy-turboattempt timed out duringvercel link.Deferred Coverage
PR 5 proves failed document requests can be answered with the fallback document. PR 8 proves a viewport-prefetched route can be reconstructed offline from persisted router records.
Docs Status
The user-facing guide and config reference land in PR 10.