mirror of
https://github.com/cloudflare/vinext.git
synced 2026-09-14 19:04:59 +08:00
f45fce00d5
* fix(isr): honor route expire ceilings Track expireAt alongside revalidateAt in the memory and KV cache handlers so ISR entries past their expire ceiling become blocking misses instead of stale responses. Plumb expireTime and request cacheLife expire values through App Router, Pages Router, prerender seeding, and cache writes while keeping generated entries as thin app-shape wiring over normal server modules. Match Next.js cache-control semantics for finite stale-while-revalidate windows when an expire value is known. * fix(isr): address cache life review follow-ups * chore: address latest review follow-ups * ci: pin vite-plus setup version * Revert "ci: pin vite-plus setup version" This reverts commit ee1d1d4e8db7b7406734414c53fa1b79f955a4d1. * fix: avoid blocking ISR page streams on cache metadata * fix: preserve headers for speculative cacheLife probes * fix: preserve prerender cacheLife metadata * fix: preserve legacy ISR cache metadata behavior * fix: preserve prerender seed revalidate context * fix: harden app page cache policy metadata * fix: resolve app router prerender conflict
42 lines
1.5 KiB
TypeScript
42 lines
1.5 KiB
TypeScript
import { describe, expect, it } from "vite-plus/test";
|
|
import {
|
|
buildCachedRevalidateCacheControl,
|
|
buildRevalidateCacheControl,
|
|
} from "../packages/vinext/src/server/cache-control.js";
|
|
|
|
describe("cache-control helpers", () => {
|
|
it("uses Next.js expire minus revalidate for finite SWR windows", () => {
|
|
expect(buildRevalidateCacheControl(60, 300)).toBe("s-maxage=60, stale-while-revalidate=240");
|
|
});
|
|
|
|
it("omits stale-while-revalidate when expire does not exceed revalidate", () => {
|
|
expect(buildRevalidateCacheControl(300, 300)).toBe("s-maxage=300");
|
|
});
|
|
|
|
it("preserves vinext's legacy unbounded SWR header when expire is unknown", () => {
|
|
expect(buildRevalidateCacheControl(60)).toBe("s-maxage=60, stale-while-revalidate");
|
|
});
|
|
|
|
it("uses route policy for STALE cached responses when expire is known", () => {
|
|
expect(buildCachedRevalidateCacheControl("STALE", 60, 300)).toBe(
|
|
"s-maxage=60, stale-while-revalidate=240",
|
|
);
|
|
});
|
|
|
|
it("uses route policy for HIT cached responses when expire is known", () => {
|
|
expect(buildCachedRevalidateCacheControl("HIT", 60, 300)).toBe(
|
|
"s-maxage=60, stale-while-revalidate=240",
|
|
);
|
|
});
|
|
|
|
it("preserves legacy STALE cached response headers when expire is unknown", () => {
|
|
expect(buildCachedRevalidateCacheControl("STALE", 60)).toBe(
|
|
"s-maxage=0, stale-while-revalidate",
|
|
);
|
|
});
|
|
|
|
it("keeps the full expire window when revalidate is zero", () => {
|
|
expect(buildRevalidateCacheControl(0, 300)).toBe("s-maxage=0, stale-while-revalidate=300");
|
|
});
|
|
});
|