Two caching bugs that taught me how Next.js 15 caches
One page had to update the moment a donation landed. Another reloaded from scratch on every click. Both were caching problems in Next.js 15, pulling in opposite directions, and naming the four caches by where they live is what solved each of them.
On this page
Every Next.js developer meets caching through one of two complaints. "I changed the data and the page didn't update." Or the opposite: "nothing changed, and the page reloads every time I open it."
I have shipped a fix for each. On Kat-Katha, a fundraising site for an NGO, a campaign's progress bar had to move the moment a donation was paid, on pages cached for speed. On this site's own admin, every click between sections reloaded the page from nothing, behind a loading skeleton, even for a section I had left three seconds earlier.
They look unrelated. They are the same lesson: Next.js has four caches in two places, and you have to know which one you are looking at.
The four caches, by where they live
- Request memoization (server, one render): the same
fetchmade twice while rendering one page runs once. - Data Cache (server, kept across requests): the results of fetches you chose to cache. You clear it by time or by tag.
- Full Route Cache (server, built ahead): the rendered output of static pages. It is why a static page is instant.
- Router Cache (the visitor's browser): pages already fetched in this tab, so going back or following a link can skip the server.
Browser └─ Router Cache pages this tab already has
Server ├─ Full Route Cache rendered static pages
├─ Data Cache fetch results you chose to keep
└─ Request memoization the same fetch, once per render
The first bug lived in the server caches. The second lived entirely in the browser.
Bug one: a donation that had to show up now
Kat-Katha's campaign pages are public, so they are cached and served without touching the database. But a donor who has just paid wants to see the bar move, and so does everyone after them.
A time-based refresh ("rebuild every 60 seconds") is a guess. It is either too slow for the donor watching the bar or wasteful for every visitor in between. The better answer was already in the system: the Razorpay webhook that settles a payment knows the exact moment something changed. So the cached reads carry a tag per campaign type, and the webhook clears that tag right after it records the payment.
The shape of it, simplified:
// The public read: cached, and tagged by campaign type.
const campaigns = await fetch(`${API}/campaigns?type=${type}`, {
next: { tags: [`campaigns:${type}`] },
});
// In the settlement webhook, after the payment is written to the ledger:
revalidateTag(`campaigns:${type}`);
The progress bar now refreshes within about a second of a captured payment, and a donation to one kind of campaign leaves the others' cached pages alone. The hard part was making that webhook settle each payment exactly once, because Razorpay may send the same event more than once; that is its own essay.
Two Next.js 15 details matter here. First, a plain fetch is no longer cached at all. Next.js 14 cached it by default, so code moved from 14 can quietly get slower; caching is now something you opt into, which is why the read above names its tag. Second, clearing a tag from a webhook clears the server's caches only. A browser tab already showing the page keeps its copy until it navigates or refreshes. For a public page that is fine; the next visitor gets the new numbers.
Bug two: the admin that forgot everything on every click
This site has an admin: a dashboard, traffic, leads, conversations, the gallery. Every page there is dynamic on purpose. The numbers are per request and behind a sign-in, and caching them on the server would be a bug, not a speed-up.
The surprise was in the browser. Next.js 15 keeps a dynamic page in the Router Cache for zero seconds. So every click on the sidebar went back to the server, drew that section's skeleton and waited for a full render. The database was not the problem: the queries take 1 to 20 ms inside Postgres. The page was simply being rebuilt from nothing on every switch.
The fix had two halves.
Keep every section prefetched, and refresh it in place. The sidebar links ask for a full prefetch of each section, so a click is served from memory with no request. A small component keeps those copies warm: when the copy on screen is more than 30 seconds old, it refreshes the page in place, inside a React transition, so there is no skeleton and nothing typed into the page is lost. It also re-prefetches the other sections afterwards, for a reason that cost me a while: router.refresh() and revalidatePath empty the whole Router Cache, not just one page, and links do not prefetch again by themselves.
// The copy on screen is older than 30s: refresh it in place.
startTransition(() => router.refresh());
// The refresh emptied the cache, so put the other sections back.
for (const href of sections) router.prefetch(href);
Then the strange part. Every section switched instantly except one: the dashboard, the page I sign in to. The page a visit lands on goes into the Router Cache as a "partial" entry, even though it holds the whole page. A full prefetch of the same address does not replace it, and with the default of zero seconds a partial entry of a dynamic page is reused only for its skeleton. So the one page I opened most was the one that still reloaded. The fix is one line:
// next.config.mjs
experimental: {
staleTimes: { dynamic: 300 },
},
That lets the browser reuse a dynamic page for up to five minutes, the same lifetime a full prefetch already gets. It does not mean five-minute-old numbers: the warming component refreshes anything older than 30 seconds, and every change made in the admin clears the cache.
Measured on a production build, signed in, before and after that one line:
| Switching to | Before | After |
|---|---|---|
| Any other section, already prefetched | no request, about 40 ms | the same |
| The dashboard | a full request and a skeleton | no request, 38–49 ms |
What I take from both
- Name the cache before you fix anything. "The page is stale" has four possible owners, and only one of them is in the browser.
- Let the event that knows clear the cache. A webhook or a save that has just changed the data should clear its tag; a timer can only guess.
- Tag the data, not the page.
revalidateTagfollows the data wherever it is shown;revalidatePathis for when one change maps cleanly onto one page. - Dynamic on the server does not have to mean slow in the browser. Prefetch, a non-zero
staleTimes.dynamicand a refresh in place give you fresh data and instant switching at once. - Measure the switch, not the query. Both problems looked like slow data; neither was.
If your Next.js app shows stale data, or rebuilds pages it has already shown, tell me about it. It is usually one cache, and finding which is most of the fix.
Frequently asked questions
- Is fetch cached by default in Next.js 15?
- No. In Next.js 15 a plain fetch is not cached: it runs on every request. Next.js 14 cached it by default. To cache a fetch now, opt in with next: { revalidate } or next: { tags }.
- What are the four caches in the Next.js App Router?
- Request memoization (the same fetch made twice in one render runs once), the Data Cache (fetch results kept across requests), the Full Route Cache (the rendered output of static pages), and the Router Cache (pages kept in the visitor's browser for fast navigation). The first three are on the server; the Router Cache is in the browser.
- Why does my dynamic page reload on every click in Next.js 15?
- Next.js 15 keeps a dynamic page in the browser's Router Cache for zero seconds by default, so every navigation to it goes back to the server. Raise experimental.staleTimes.dynamic in next.config to let the browser reuse it, and refresh the page yourself when its data gets old.
- What's the difference between revalidateTag and revalidatePath?
- revalidateTag clears every cached entry carrying a tag, wherever that data is used, so it suits "this data changed". revalidatePath clears one route, so it suits "this page changed". Tag the data and revalidate the tag when you can.

Kat-Katha
NGO Giving Platform
A full-stack giving site for a Delhi NGO — a hardened Razorpay donation pipeline with live campaign progress, plus a custom CMS the team runs themselves to publish stories, programs, and campaigns.
Next.js 15 · Vercel Postgres · Razorpay

AI Assistant
RAG Twin + Analytics Co-pilot
Two assistants on one corpus. Visitors get an AI twin that answers questions about my work from this site's own pages, not from the model's memory. I get a co-pilot inside the admin that reads the site's traffic, leads and twin conversations and turns them into answers and next steps.
Next.js · TypeScript · Supabase
Most portfolios are a page of links. This one answers questions about my work, keeps its own leads and traffic, manages its own photos and checks itself on every change. Here is every part of it, how each one works, and the problems that decided how it is built.
If you are deciding whether to hire me, the stack matters less than how I make decisions. These are the six rules I keep on every build, each with the project that taught it to me, and most with a link to the evidence.