Interview kitsBlog

Your dream job? Lets Git IT.
Interactive technical interview preparation platform designed for modern developers.

XGitHub

Platform

  • Categories

Resources

  • Blog
  • About the app
  • FAQ
  • Feedback

Legal

  • Privacy Policy
  • Terms of Service

© 2026 LetsGit.IT. All rights reserved.

LetsGit.IT/Categories/Next.js
Next.jsmedium

App Router data fetching — how does Next.js cache `fetch()` by default?

Tags
#fetch#revalidate#cache
Back to categoryPractice quiz

Answer

In Server Components, Next can cache `fetch()` results and dedupe requests. You can opt out with `cache: 'no-store'` or set revalidation with `next: { revalidate: seconds }` to control freshness.

const res = await fetch('https://example.com/api', {
  next: { revalidate: 60 },
})

Advanced answer

Deep dive

In the App Router, `fetch()` used in **Server Components** participates in Next.js caching:

  • **Request memoization**: identical fetches during a single render are deduped.
  • **Data cache** (when allowed): results can be reused across requests, enabling SSG/ISR-like behavior.

By default, Next caches GET-like requests when it can (similar to `force-cache`). You can opt out or control freshness using revalidation.

Controls

Disable caching (SSR-like):

await fetch(url, { cache: 'no-store' })

Revalidate after N seconds (ISR-like):

await fetch(url, { next: { revalidate: 60 } })

What can force dynamism

Reading request-specific values like `cookies()` or `headers()` can make a route dynamic, which affects caching.

Common pitfalls

  • Assuming client-side `fetch` uses the same cache (it doesn’t; that’s browser caching).
  • Forgetting that headers/credentials affect the cache key.

Related questions

Next.js
App Router data fetching: what do `cache: 'no-store'` and `revalidate` change?
#nextjs#fetch#cache
Next.js
Cache invalidation: what do `revalidatePath` and `revalidateTag` do?
#nextjs#cache#revalidate
Next.js
What does `router.refresh()` do in the App Router (and when use it)?
#nextjs#router
  • Expecting POST requests to be cached like GET requests.
  • #refresh
    Next.js
    Static vs dynamic rendering — how do you force a route to be dynamic and why?
    #ssr#dynamic#cache
    Next.js
    Explain caching and revalidation in Next.js (fetch cache, revalidatePath).
    #caching#revalidation#fetch