Skip to content

fix(cache): share query-independent response entries - #3390

Draft
james-elicx wants to merge 44 commits into
mainfrom
codex/query-independent-response-cache
Draft

james-elicx wants to merge 44 commits into
mainfrom
codex/query-independent-response-cache

Conversation

@james-elicx

@james-elicx james-elicx commented Sep 22, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Rebuild App Router query-string sharing around each adapter's admission boundary. Workers Response Store looks up a proven-eligible Server Page by pathname and representation, renders a miss with its original query, and stores only completed query-independent artifacts. Workers Cache canonicalizes the entrypoint URL and ctx.props only when explicit static/error route config or an exact-path/representation cacheability manifest supplies pre-lookup evidence. Otherwise the query stays in the key.
  • Static/error App Route Handlers also share by pathname; revalidate-only handlers remain query-keyed because eligibility alone does not prove independence. Explicit public dynamic responses remain full-query keyed. Client Pages without an explicit static contract conservatively bypass Response Store: prop serialization before client execution cannot prove an unused query.
  • Preserve Fetch Cache, use cache, Pages Router, rewrite destination, and representation boundaries. Add existing-demo-fixture regressions across KV, Workers Cache, Response Store service-binding and self-contained modes, including on-demand static exports, static handlers, HTML/RSC, client SSR, metadata, and explicit public policy.

Parity and safety

Next.js treats Page searchParams as a dynamic API (docs, test). A completed query-independent Server Page artifact is reusable by pathname; explicitly static routes provide build-time proof even for nonstandard default exports. A force-static Route Handler strips its request query (test). Explicit public policy may instead cache dynamic output separately by query (test).

A default Client Page currently cannot distinguish actual searchParams consumption from React's serialization of the client-reference prop. Workers Cache therefore keeps unproven Client Pages query-keyed; Response Store bypasses default Client Pages rather than admitting an empty-query false static artifact. This creates extra misses for Client Pages that ignore the prop, but prevents cross-query leakage. Workers Cache still buffers some cold misses before delivery, as before this PR; this change does not claim streaming-miss parity. Cache Components/PPR postponed-shell parity remains out of scope.

Verification

  • Focused local suites: ISR/App Page 130/130, Response Store data 18/18, and Response Store Miniflare 23/23 passed; changed-file checks passed.
  • Exact head 672c41614e7a6729feb36a26eb4b2d7645dc0038: CI passed (55 jobs). Deploy Examples passed on attempt 2. KV, Workers Cache, and Response Store deployed cache E2Es all passed on their first attempt; the unrelated preview smoke job passed on retry after a shell broken-pipe false negative (the same preview smoke script passed locally, 20/20).
  • Five independent reviews were clean at this head; timed Big Bonk returned LGTM.

Keep this PR draft for human review; do not merge or mark ready automatically.

@james-elicx
james-elicx marked this pull request as draft September 22, 2026 16:18
@pkg-pr-new

pkg-pr-new Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@vinext/cloudflare

npm i https://pkg.pr.new/@vinext/cloudflare@3390

create-vinext-app

npm i https://pkg.pr.new/create-vinext-app@3390

@vinext/types

npm i https://pkg.pr.new/@vinext/types@3390

vinext

npm i https://pkg.pr.new/vinext@3390

@cloudflare/workers-response-store

npm i https://pkg.pr.new/@cloudflare/workers-response-store@3390

commit: 7bd07d0

@github-actions

github-actions Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Performance benchmarks

Compared 7bd07d0 against base 79a2d11 using alternating same-runner rounds. Next.js was unchanged and skipped.

0 improved · 0 regressed · 6 within ±1.5%

Scenario Framework Baseline Current Change
Client bundle size (gzip) vinext 142.3 KB 143.9 KB ⚫ +1.1%
Client entry size (gzip) vinext 129.7 KB 131.3 KB ⚫ +1.2%
Dev server cold start vinext 3.23 s 3.22 s ⚫ -0.4%
Production build time vinext 3.50 s 3.53 s ⚫ +0.9%
RSC entry closure size (gzip) vinext 127.9 KB 129.7 KB ⚫ +1.5%
Server bundle size (gzip) vinext 226.2 KB 228.9 KB ⚫ +1.2%

View detailed results and traces

🟢 improvement · 🔴 regression · ⚫ change below 1.5% · paired base/head

@github-actions

Copy link
Copy Markdown
Contributor
Example Preview Production Original
app-router-cloudflare preview production
pages-router-cloudflare preview production
app-router-playground preview production original
realworld-api-rest preview production
nextra-docs-template preview production
benchmarks preview production
hackernews preview production original
response-store-demo preview production
workers-cache preview production
kv preview production
static-export preview production
web preview production

@james-elicx

Copy link
Copy Markdown
Member Author

/bigbonk review for issues

Time limit: 8 minutes. Complete the review and post all findings within that limit.

@ask-bonk

ask-bonk Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

LGTM!

github run

@james-elicx

Copy link
Copy Markdown
Member Author

/bigbonk review for issues

Time limit: 8 minutes. Complete the review and post all findings within that limit.

@ask-bonk

ask-bonk Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

LGTM!

github run

@james-elicx

Copy link
Copy Markdown
Member Author

/bigbonk review for issues

Time limit: 8 minutes. Complete the review and post all findings within that limit.

@ask-bonk

ask-bonk Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

LGTM!

github run

@james-elicx

Copy link
Copy Markdown
Member Author

/bigbonk review for issues

Time limit: 8 minutes. Complete the review and post all findings within that limit.

@ask-bonk

ask-bonk Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

LGTM!

github run

@james-elicx

Copy link
Copy Markdown
Member Author

/bigbonk review for issues

Time limit: 8 minutes. Complete the review and post all findings within that limit.

@ask-bonk

ask-bonk Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

LGTM!

github run

@james-elicx

Copy link
Copy Markdown
Member Author

/bigbonk review for issues

Time limit: 8 minutes. Complete the review and post all findings within that limit.

@ask-bonk

ask-bonk Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

LGTM!

github run

@james-elicx
james-elicx force-pushed the codex/query-independent-response-cache branch from 3d6dc29 to 5932366 Compare September 22, 2026 22:42
@james-elicx

Copy link
Copy Markdown
Member Author

/bigbonk review for issues

Time limit: 8 minutes. Complete the review and post all findings within that limit.

@ask-bonk

ask-bonk Bot commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

LGTM!

github run

// path, not runtime-attacker-controlled input — a false positive.
imports.push(`const ${varName} = () => import(${JSON.stringify(absPath)});`);
imports.push(
`const ${varName} = () => import(${JSON.stringify(absPath)})${clientConfig && Object.keys(clientConfig).length > 0 ? `.then((mod) => ({ ...mod, ...${JSON.stringify(clientConfig)} }))` : ""};`,
// path, not runtime-attacker-controlled input — a false positive.
imports.push(`const ${varName} = () => import(${JSON.stringify(absPath)});`);
imports.push(
`const ${varName} = () => import(${JSON.stringify(absPath)})${clientConfig && Object.keys(clientConfig).length > 0 ? `.then((mod) => ({ ...mod, ...${JSON.stringify(clientConfig)} }))` : ""};`,
// path, not runtime-attacker-controlled input — a false positive.
imports.push(`const ${varName} = () => import(${JSON.stringify(absPath)});`);
imports.push(
`const ${varName} = () => import(${JSON.stringify(absPath)})${clientConfig && Object.keys(clientConfig).length > 0 ? `.then((mod) => ({ ...mod, ...${JSON.stringify(clientConfig)} }))` : ""};`,
@james-elicx

Copy link
Copy Markdown
Member Author

/bigbonk review for issues

Time limit: 8 minutes. Complete the review and post all findings within that limit.

@ask-bonk

ask-bonk Bot commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

LGTM!

github run

@james-elicx

Copy link
Copy Markdown
Member Author

/bigbonk review for issues

Time limit: 8 minutes. Complete the review and post all findings within that limit.

@ask-bonk

ask-bonk Bot commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

LGTM!

github run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants