Skip to content

Commit b1e5316

Browse files
committed
fix(cache): preserve routing vetoes during probing
1 parent 6cc1d5a commit b1e5316

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

packages/vinext/src/server/cacheability-request.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,9 @@ function completedRouteOutcome(
416416
response: Response,
417417
state: RouteCacheabilityState,
418418
): RouteCacheabilityOutcome | null {
419+
if (state.forcedDynamicReason) {
420+
return { cacheable: false, reason: state.forcedDynamicReason };
421+
}
419422
if (state.route?.kind !== "pages-page") return state.outcome ?? null;
420423
if (
421424
response.headers.has("set-cookie") ||

tests/e2e/ppr-impact-demo/pages-cacheability.spec.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,27 @@ test("classifies Pages Router data contracts inside the staged Worker", async ({
8888
status: 200,
8989
version: 1,
9090
});
91+
92+
for (const [pathname, reason] of [
93+
["/cacheability-pages/middleware", "middleware is eligible for this pathname"],
94+
[
95+
"/cacheability-pages/config-header",
96+
"next.config headers depend on request headers, cookies, or hostnames",
97+
],
98+
] as const) {
99+
const response = await request.get(pathname, {
100+
headers: { ...headers, Accept: "text/html" },
101+
});
102+
expect(response.ok(), pathname).toBe(true);
103+
await expect(response.json(), pathname).resolves.toMatchObject({
104+
kind: "pages-page",
105+
pattern: pathname,
106+
reason,
107+
state: "dynamic",
108+
status: 200,
109+
version: 1,
110+
});
111+
}
91112
});
92113

93114
test("admits only exact manifest-backed Pages Router responses", async ({ request }) => {

0 commit comments

Comments
 (0)