Part 10 / Topic 3 of 6
cacheLife profiles — this install's real numbers, and a genuine surprise
Reading this install's own config, not assuming: node_modules/next/dist/server/config-shared.js defines the preset cacheLife profiles that ship with every app using Cache Components (seconds shown):
| Profile | stale |
revalidate |
expire |
|---|---|---|---|
default |
300 (5 min) | 900 (15 min) | INFINITE_CACHE (0xfffffffe ≈ 136 years, capped at this install's expireTime config of 1 year when it reaches an actual response header — see the going-deeper note) |
seconds |
30 | 1 | 60 |
minutes |
300 | 60 | 3600 |
hours |
300 | 3600 | 86400 |
days |
300 | 86400 | 604800 |
weeks |
300 | 604800 | 2592000 |
max |
300 | 2592000 | 31536000 |
Swapping getDailyStats's cacheLife('hours') for cacheLife('seconds') (kept as a second function, getDailyStatsFast, so both exist side by side) looked, at first, like it should just mean "refreshes more often." Building it exactly like section 2's page — no <Suspense> — reproduced a real build error:
$ npm run build
...
Error: Route "/mandi/stats/fast": Next.js encountered runtime data during prerendering.
`cookies()`, `headers()`, `params`, or `searchParams` accessed outside of `<Suspense>` prevents the route from being prerendered...
The error message's wording is almost the same family as section 1's genuinely-uncached case — and node_modules/next/dist/docs/01-app/03-api-reference/04-functions/cacheLife.md's own "Prerendering behavior" section explains exactly why: "revalidate of 0, or expire under 5 minutes: excluded from prerenders, becoming a 'dynamic hole' resolved at request time." 'seconds''s expire is 60 seconds — under 5 minutes — so Cache Components refuses to bake it into the static shell at all, cached directive or not. The fix is the same one section 1 already needed:
// harness/app/mandi/stats/fast/page.tsx
async function FastStats() {
const stats = await getDailyStatsFast();
return <>{/* ... */}</>;
}
export default function StatsFastPage() {
return (
<main>
<Suspense fallback={<p id="fallback">Loading…</p>}>
<FastStats />
</Suspense>
</main>
);
}
With <Suspense> in place, the build succeeds, and the real build table shows the difference between the two stats pages directly:
├ ○ /mandi/stats 1h 1d
├ ◐ /mandi/stats/fast
/mandi/stats is fully static (○) with a Revalidate/Expire column; /mandi/stats/fast is a Partial Prerender (◐) — a static shell around a genuine request-time hole, headers confirming it the same way section 1's did (x-nextjs-postponed: 1, Cache-Control: private, no-cache, no-store). Hitting it repeatedly, 1.5 seconds apart, over a real next start:
$ for i in 1 2 3 4; do curl -s http://localhost:PORT/mandi/stats/fast | grep -o 'computed-at">[^<]*'; sleep 1.5; done
computed-at">2026-12-01T11:08:10.732Z
computed-at">2026-12-01T11:08:12.898Z
computed-at">2026-12-01T11:08:15.068Z
computed-at">2026-12-01T11:08:17.244Z
A new value every single time at this 1.5-second spacing — revalidate: 1 means almost every request past that one second window triggers a fresh computation, which is exactly the real-time-data use case 'seconds' exists for (the docs name "stock prices, live scores"). Full file: examples/04-stats-fast-page.tsx.
🔍 Going deeper — the
defaultprofile's "never" isn't infinite in a response header:top-categories/page.tsx(section 4) calls nocacheLifeat all, so it gets the implicitdefaultprofile. Its real response header readsCache-Control: s-maxage=900, stale-while-revalidate=31535100.900isdefault's 15-minuterevalidate, exactly as the table above says. But31535100is not derived fromdefault's rawexpire(INFINITE_CACHE,0xfffffffe≈ 136 years) — it's31536000 - 900, where31536000is exactly one year in seconds. This install's globalconfig-shared.jsdefault,expireTime: 31536000, is a separate, top-level cap on how long a CDN is told it may hold a "never expires" entry — confirmed by reading that exact field in the same config file thecacheLifetable above came from. The build's own route table independently agrees: it showstop-categories'sExpirecolumn as1y, not some astronomically large number. Don't assumedefault's "infinite" expire shows up as infinite anywhere a real HTTP client can see — it's capped before it ever leaves the server.
Done here? The practice set for Part 10 — including the solutions — is on the part page.