Question presented to candidate: "Walk me through the options you can pass to fetch in a Server Component and what each does to caching and to the route. What is the default today?"
What a strong answer should cover:
- By default a fetch result is not stored across requests (since Next.js 15), but a fetch reached during a static render runs at build time and its result is baked into the page.
cache: 'force-cache'stores the result in the Data Cache and reuses it across requests, even in a dynamic route.cache: 'no-store'fetches on every request and makes the route dynamic.next: { revalidate: n }stores the result for n seconds, then serves the stale value while refetching in the background.next: { tags: [...] }labels the entry sorevalidateTagcan clear it on demand; these options belong to the previous model, while Cache Components uses 'use cache'.
Clarifying questions expected:
- "How fresh does this data have to be?" β seconds, minutes, or exact.
- "Is Cache Components on?" β then fetch options give way to 'use cache' and cacheLife.
Code / implementation expected: Yes β the four fetch styles and what the build makes of them.