Static shell plus a streamed dynamic hole
A model of partial prerendering with real react-dom/server streaming: in Next.js the first chunk would be saved at build time and served from a CDN, and only the UserPreferences part would be rendered per request.
In Next.js 16 server components await their data directly; with Cache Components enabled you cache functions or components with "use cache", set lifetimes with cacheLife, tag them with cacheTag and refresh them with revalidateTag, updateTag or revalidatePath, while request-time data streams behind <Suspense>, so one route can be part static, part dynamic.
Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.
Ready for more? This phase has 5 hands-on exercises with automatic checks.
Practice questions
Write the code in the editor, run it, then open the model answer to compare.
Write a cached getCategory(slug) that lasts a day and can be refreshed by the tag categories.
A product page shows product details (same for everyone) and "Recently viewed" (from a cookie). Write the page so the details are in the static shell.
Explain it without notes
How do you fetch data in a Next.js server component, and how do you avoid waterfalls?
What makes part of a route dynamic, and how does Cache Components handle it?
Explain "use cache", cacheLife and cacheTag. What is part of the cache key?
Compare revalidateTag, updateTag and revalidatePath.
Preview
Console
Nothing logged yet.Expected console output
static shell: Our Blog | Server Components | Caching in Next.js | Loading your preferences...
streamed hole: Our Blog | Server Components | Caching in Next.js | Your theme: dark