Skip to content

Enable Cache Components - #25

Merged
GregorGabric merged 2 commits into
mainfrom
cache-components-adoption
Jun 25, 2026
Merged

GregorGabric merged 2 commits into
mainfrom
cache-components-adoption

Conversation

@GregorGabric

Copy link
Copy Markdown
Owner

What

Enables cacheComponents: true in apps/preskok and makes every route prerenderable. Direct adoption — no instant = false opt-outs anywhere.

next build is green: all 266 pages generate. Verified at runtime against next start (not just the build).

Changes

Removed configs that error under the flag (this canary, 16.3.0-canary.66, also rejects dynamicParams, not just dynamic/revalidate/fetchCache):

  • Dropped them from the docs page, view page, examples layout, and the og/llms route handlers. Unknown params still 404 via the existing in-handler notFound() checks.

Cached static data access ("use cache" + cacheLife("max")):

  • index.md, llms.txt, llms-full.txt, llms.mdx/* cache their generated text, keyed by serializable slugs.
  • getRegistryItem (registry source is static).

Deferred request-time / unstable reads behind <Suspense> so shells prerender:

  • Live previews call today() (Date.now()) → wrapped <Component/> in Suspense at each embed site (component-preview, view/[name], theme <Blocks/>).
  • fumadocs ServerCodeBlock reads Date.now() during client-component SSR (can't be cached) → ComponentCode uses await connection() + Suspense to render registry code blocks at request time.

Resulting route types

  • Partial Prerender: docs pages, most /view/* (static shell + streamed code/previews)
  • Static: /theme, /components, /examples/authentication, /llms.txt, /index.md, /llms-full.txt
  • ƒ Dynamic: /api/search, /og, /og/docs/*, /llms.mdx/* (genuinely request-time)

Reviewer notes / trade-offs

  • Registry code blocks now render at request time (stream in) rather than being baked into the static HTML — forced by fumadocs reading Date.now() during highlight SSR. Worth a fumadocs issue if we want them static again.
  • revalidate = falsecacheLife("max") surfaces as Revalidate 30d / Expire 1y (was "never"). Negligible for deploy-rebuilt content.
  • /og/docs/* and /llms.mdx/* are now ƒ rather than prebuilt-static; both verified working.
  • next dev over-reports these as blocking-prerender errors even where connection() makes the subtree legitimately dynamic — trust next build.

🤖 Generated with Claude Code

Turn on `cacheComponents: true` and make every route prerenderable
(Direct adoption — no `instant = false` opt-outs).

Prerequisite config removal (these error under the flag; this canary also
rejects `dynamicParams`):
- Drop `dynamic`/`revalidate`/`dynamicParams` from the docs page, view page,
  examples layout, and the og/llms route handlers. Unknown params still 404
  via the existing in-handler `notFound()` checks.

Make data access prerenderable:
- Route handlers (`index.md`, `llms*.txt`, `llms.mdx/*`) cache their generated
  text with `"use cache"` + `cacheLife("max")`, keyed by serializable slugs.
- `getRegistryItem` is cached with `"use cache"` (registry source is static).

Defer request-time / unstable reads behind Suspense so the shells prerender:
- Live component previews call `today()` (`Date.now()`); wrap `<Component/>` in
  Suspense at each embed site (component-preview, view page, theme Blocks).
- fumadocs `ServerCodeBlock` reads `Date.now()` during client-component SSR,
  which can't be cached; `ComponentCode` uses `await connection()` + Suspense to
  render registry code blocks at request time.

`next build` is green; docs/view pages are Partial Prerender (◐), text routes
are static, og/search/llms.mdx are dynamic (ƒ).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 25, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ui Ready Ready Preview, Comment Jun 25, 2026 11:08am

@GregorGabric
GregorGabric merged commit 2e2c91f into main Jun 25, 2026
5 checks passed
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.

1 participant