Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Next.js and React

Next.js shows old data even though fetch uses cache: 'no-store'

Errorfetch(url, { cache: 'no-store' }) returns the same data after the source changed

Short answer

A fetch with cache: 'no-store' is re-fetched on every request, so stale data means something else decides. Check four things in order: a route segment config such as fetchCache or dynamic that overrides the option, data that is not read through fetch at all, a conflicting revalidate option, and in development the HMR cache.

  • Applies to Next.js 15, Next.js 16, Node.js 22
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Turn on fetch logging in development. It prints every fetch with a cache hit or miss, which shows whether the request is cached at all or whether the page itself is prerendered.

    // next.config.ts
    const nextConfig = {
      logging: { fetches: { fullUrl: true } },
    }
    export default nextConfig
  2. 2Match what you see, then jump to its fix

    1. 1Your fetch says no-store, but the page or a parent layout exports fetchCache or dynamicA segment config overrides the fetch optionFix
    2. 2The data comes from an ORM, a database driver or an SDK, and the page is prerendered at build timeThe data is not read through fetchFix
    3. 3A warning in the dev terminal about conflicting options on a fetchConflicting cache and revalidate options on one fetchFix
    4. 4Fresh data after a full page reload, stale data after saving a fileOnly in development: the HMR cacheFix

What does the error look like?

  • fetch(url, { cache: 'no-store' }) returns the same data after the source changed
  • Page shows old data in production but fresh data after a restart
  • Fresh data on full reload but not after saving a file in next dev

Cause 1 of 4

A segment config overrides the fetch option

1Check

Search the route's page, layout and route files for exported segment options. fetchCache = 'force-cache' sets the cache option of every fetch in that segment to force-cache, and dynamic = 'force-static' or 'error' prerenders the route.

grep -rn "export const \(fetchCache\|dynamic\|revalidate\)" app/

2Fix

Remove the option, or set the one you mean. For a page that must be fresh on every request, force dynamic rendering for that segment.

// page.tsx or layout.tsx
export const dynamic = 'force-dynamic'

3Verify

Build and start the production server, change the source data, reload the page twice.

npm run build && npm run start

Confirmed by nextjs.org

Did this fix it?

Cause 2 of 4

The data is not read through fetch

1Check

The fetch cache options only apply to fetch. A route with no Request-time API and no uncached fetch is prerendered during next build, so its data is frozen into the build.

npm run build
# then read the route list the build prints for your page

2Fix

Opt the route out of prerendering. Force dynamic rendering, or cache the function on purpose with unstable_cache and a revalidate time.

import { unstable_cache } from 'next/cache'

export const getPosts = unstable_cache(
  async () => db.select().from(posts),
  ['posts'],
  { revalidate: 60 }
)

3Verify

After the change, update a row in the database and confirm the page shows it within the time you set, or at once with force-dynamic.

npm run build && npm run start

Confirmed by nextjs.org

Did this fix it?

Cause 3 of 4

Conflicting cache and revalidate options on one fetch

1Check

Look for a fetch that sets both next.revalidate with a number and cache: 'no-store'. Next.js ignores both when they conflict.

grep -rn "no-store" app/ lib/ | grep revalidate

2Fix

Keep one of them. Use cache: 'no-store' for always fresh, or next.revalidate for a time limit.

const res = await fetch(url, { cache: 'no-store' })
// or
const res2 = await fetch(url, { next: { revalidate: 60 } })

3Verify

Restart next dev and confirm the warning is gone.

npm run dev

Confirmed by nextjs.org

Did this fix it?

Cause 4 of 4

Only in development: the HMR cache

1Check

In next dev, Server Component fetch responses are kept across hot module replacement refreshes, including no-store requests. Navigation or a full reload clears them.

grep -n "serverComponentsHmrCache" next.config.*

2Fix

Reload the page fully, or switch the experimental cache off in the config.

// next.config.ts
const nextConfig = {
  experimental: { serverComponentsHmrCache: false },
}
export default nextConfig

3Verify

Restart next dev, edit a file and watch the data change on the next refresh.

npm run dev

Confirmed by nextjs.org

Did this fix it?

How do I stop it coming back?

  • Test caching behaviour with next build and next start, not only next dev.
  • Set one caching rule per route and put it where the next reader will look, at the top of the page file.
  • Keep logging.fetches on in development so cache hits are visible.
  • Use cache: 'force-cache' or next.revalidate only on data you are happy to serve old.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.