Home / Insights / Web and SaaS Development

Web and SaaS Development

Next.js Performance and Caching: Getting Fast Pages Without Stale Data

The Next.js App Router can make pages very fast by caching aggressively, but the same defaults are behind most complaints about prices, stock levels or dashboards showing old data. This guide explains the four cache layers, how to decide freshness per route, and how to roll out caching without surprises.

TopicsWeb and SaaS DevelopmentArchitecture and Modernization

Key takeaways

  • Next.js 14 has four cache layers (request memoisation, Data Cache, Full Route Cache and the client Router Cache); stale data almost always comes from not knowing which layer holds the old value.
  • Decide freshness per data source, not per app: write down how old each piece of data may be, who is harmed if it is old, and what event changes it.
  • Prefer event-driven invalidation with tags for content that changes on publish or on user action, and time-based revalidation only where a known delay is acceptable.
  • Keep personalised and permission-dependent data out of shared caches entirely, and treat that as a security rule, not a performance tweak.
  • The Next.js 15 release candidate flips several defaults to uncached, so make caching explicit in code now and upgrades become far less risky.

Teams usually adopt Next.js for two reasons: fast first page loads and good search visibility. The App Router, stable since Next.js 13.4 and refined in 14, delivers both largely through caching. The catch is that it caches at several levels by default, and the first time a product manager reports that a price change has not appeared, or a customer sees an order status from ten minutes ago, the team discovers how many layers there are.

This article is for CTOs, engineering leads and product owners running or planning a Next.js product, whether a marketing site with a headless CMS, an e-commerce storefront or a logged-in SaaS dashboard. It explains where Next.js caches, how to decide how fresh each piece of data needs to be, which invalidation strategy fits which case, and how to implement and test caching so speed does not come at the cost of correctness. It reflects how we approach this on Next.js projects at PoliteTech, where our developers work on server-rendered sites, API routes, headless CMS integration and React-to-Next.js migrations.

Where Next.js caches: the four layers behind fast and stale pages

The official Next.js 14 caching documentation describes four mechanisms. Each has a different location, lifetime and way of being cleared, and confusing them is the root of most stale-data bugs.

LayerWhat it storesWhereHow long (Next.js 14 defaults)How it is cleared
Request memoisationResults of identical GET fetches during one renderServer memoryOne requestAutomatically after the render
Data CacheResponses from fetch callsServer (persistent)Until revalidated, across requests and deploymentsTime-based revalidate, revalidateTag, revalidatePath
Full Route CacheRendered HTML and React Server Component payload for static routesServer (persistent)Until data is revalidated or the app is redeployedRevalidating its data, or a new deployment
Router CacheServer Component payloads of visited and prefetched route segmentsBrowser memoryThe session, with segments invalidated after 30 seconds (dynamic) or 5 minutes (static)router.refresh, revalidation inside a Server Action, cookie changes in a Server Action, page reload

Why the layering surprises people

Three behaviours catch most teams out. First, in Next.js 14 a fetch call is cached by default unless you opt out, so a page that reads prices from an API can become a static page without anyone deciding that it should. Second, the Data Cache persists across deployments, so redeploying does not necessarily clear old data, while the Full Route Cache is cleared on deployment. Third, the documentation is explicit that you cannot opt out of the client-side Router Cache; revalidating data from a Route Handler (for example, a CMS webhook) does not immediately invalidate what a user already has in their browser session.

The practical consequence is that stale data reported by a user can live in any of three places: the Data Cache on the server, the pre-rendered route, or the browser’s Router Cache. Debugging starts with identifying which.

What is changing

The Next.js 15 release candidate, announced in May 2024, changes the defaults: fetch requests, GET Route Handlers and Page segments in the client Router Cache become uncached by default, and you opt in to caching instead. That is a release candidate, not a stable release, so production apps today still run the version 14 defaults. It is a strong signal, though, that relying on implicit caching is a liability.

How fresh does each piece of data need to be?

The most useful step happens before anyone writes code: classify data by how stale it may safely be. Freshness is a product and risk decision, not a framework setting, so product owners should be in the conversation.

Four questions per data source

  1. What is the maximum acceptable age? Seconds, minutes, hours or until the next publish.
  2. Who is harmed if it is stale, and how badly? A blog post one minute out of date harms nobody; a stock level that lets a customer buy an item that has sold out creates a refund and a complaint; a permission change that has not taken effect is a security issue.
  3. What changes it? An editor publishing, a user action in your own app, a third-party system, or simply time passing.
  4. Is it the same for every visitor? Shared data can be cached centrally. Personalised or permission-dependent data must not sit in a shared cache.

A freshness classification you can use

ClassTypical examplesAcceptable stalenessSuggested approach
Static contentMarketing pages, documentation, blog postsUntil next publishStatic rendering plus tag-based revalidation from a CMS webhook
Slow-changing shared dataProduct descriptions, category lists, store locationsMinutes to hoursCached fetch with time-based revalidation, plus tags for urgent edits
Fast-changing shared dataPrices during a sale, stock levels, event availabilitySeconds, or must be confirmed at the point of decisionShort revalidation for display, and an uncached check at add-to-cart or checkout
Personalised dataAccount details, orders, dashboards, entitlementsMust be current for that userDynamic rendering, no shared caching, invalidate in the Server Action that changes it

For example, a mid-sized online retailer might decide that product copy can be up to an hour old, displayed prices up to sixty seconds, and that the basket must always re-check price and stock without any cache. That single decision removes most arguments later, because engineers can map each class to a specific Next.js pattern.

Static, revalidated or dynamic: choosing the rendering mode per route

Once data is classified, each route gets a rendering strategy. A route’s mode is determined by the data it uses: if any data in the route is uncached, or if the route reads request-specific information such as cookies, headers or search parameters, Next.js renders it dynamically on each request.

The options and their trade-offs

OptionSpeed for usersServer costFreshness riskBest for
Fully static (build time)FastestLowestStale until rebuild or revalidationContent that changes on publish
Static with time-based revalidationVery fastLowUp to one revalidation window old, and the first visitor after expiry still sees the old version while it refreshesShared data with a known tolerance
Static with on-demand (tag or path) revalidationVery fastLowLow, if every change triggers revalidation reliablyCMS content, catalogue updates driven by events
Dynamic with cached dataFastMediumOnly the uncached parts are guaranteed freshPages mixing personal and shared data
Fully dynamic, uncachedSlowest of the five; depends on your data sourcesHighestNone at the server, but the browser Router Cache still appliesDashboards, account pages, anything permission-dependent

Time-based revalidation is stale-while-revalidate

Time-based revalidation in Next.js behaves like the HTTP stale-while-revalidate pattern. According to the documentation, once the window has passed, the next request still receives the cached value while a background refresh runs; if that refresh fails, the old data is kept. That is good for resilience and speed, but it means a revalidate value of 60 does not guarantee data is under 60 seconds old for every visitor. If a figure must be current at a decision point, fetch it uncached at that point.

Mixed pages are normal

A product page can combine cached description and images with an uncached stock check. Opting out of the Data Cache for one fetch makes the route dynamic, but other fetches in the same route stay cached. Wrapping the fresh part in a React Suspense boundary lets the cached shell render quickly while the dynamic part streams in. The experimental Partial Prerendering feature in the 15 release candidate formalises this static-shell, dynamic-hole approach, but it is not something to rely on in production yet.

Invalidation strategies that keep data correct

Caching is easy; invalidation is where correctness lives. Next.js gives you three tools, and choosing the right one per data class matters more than any individual setting.

Tags for event-driven content

Tag fetches with meaningful names (for example a product identifier and a collection name) and call revalidateTag when the underlying data changes. For CMS content, a webhook from the CMS to a Route Handler that revalidates the relevant tags gives near-immediate updates without giving up static performance. Keep a short, documented list of tag names; ad hoc tags multiply quickly and become impossible to reason about.

Paths for page-level changes

revalidatePath clears the data and re-renders everything under a path. It is simpler than tags but blunter. Use it for small sites or for changes that genuinely affect a whole section, such as a navigation update.

Server Actions for changes your own users make

When a user updates something in your app, revalidate inside the Server Action that performs the mutation. The documentation notes that revalidating in a Server Action also invalidates the Router Cache for the affected route, whereas revalidating in a Route Handler does not immediately clear it. In practice this is the difference between a user saving a setting and seeing it at once, and seeing the old value until they reload.

Common invalidation failures

  • Missed events: a bulk import or a direct database edit bypasses the code path that revalidates. Route every write through a function that also revalidates, or add a scheduled safety net.
  • Webhook failures: CMS webhooks fail silently. Log every revalidation call, alert on errors, and keep a manual revalidate endpoint protected by a secret.
  • Over-broad invalidation: revalidating the root path on every edit throws away most of your cache and pushes load onto your origin.
  • Forgotten client cache: fixing the server and leaving the 30-second Router Cache window in place still produces reports of stale screens after mutations from other tabs or other users.

Keeping personalised data out of shared caches

The most serious caching bug is not stale data; it is one user seeing another user’s data. That can happen when a response that depends on who is logged in is stored somewhere shared: the Data Cache, the Full Route Cache, or a CDN in front of the app.

Rules we apply

  • Any fetch that sends user credentials or returns user-specific data is explicitly marked cache: 'no-store', even where the framework would make the route dynamic anyway. Explicit beats implicit, especially with defaults about to change.
  • Pages that read cookies or headers to decide what to show are dynamic. Do not work around this by moving the check into a client component while the server still renders shared data that depends on the user.
  • For HTTP responses served through a CDN, use the right Cache-Control directives. As MDN’s Cache-Control reference explains, private restricts storage to the browser, no-store prevents any cache from storing the response, and s-maxage applies only to shared caches such as CDNs.
  • Use cookie changes in Server Actions for sign-in and sign-out, which the documentation states invalidates the Router Cache so routes depending on authentication do not show the previous state.

Treat these as security controls and include them in code review. They sit alongside other baseline protections, such as those in our guide to web application security headers and CSP.

Implementing caching on a new or existing Next.js app

Whether you are starting fresh or fixing an app that already shows stale data, the sequence is similar.

  1. Inventory data sources. List every API, database query and CMS call, which routes use it, and assign it a freshness class from the table above.
  2. Make caching explicit. Add a cache option or next.revalidate to every fetch, and wrap non-fetch data access (ORM queries, SDK calls) in a small data layer with clear caching behaviour. This also prepares you for the Next.js 15 default changes.
  3. Define tags and owners. Agree tag names per entity type and decide which event triggers which revalidation.
  4. Wire up invalidation. Add revalidation to every Server Action that writes data, and to CMS or third-party webhooks via Route Handlers, with logging.
  5. Check build output. The build summary shows which routes are static and which are dynamic. Compare it with your intended plan; an accidentally static dashboard or an accidentally dynamic marketing page shows up here.
  6. Measure real users. Track Core Web Vitals from the field. Since March 12, 2024, Interaction to Next Paint has replaced First Input Delay as a Core Web Vital, so interactivity after load matters as much as the first render.
  7. Document behaviour for the business. Tell content editors and support staff exactly how long changes take to appear, and how to force an update.

Testing freshness, not just speed

Performance tests tell you pages are fast; they do not tell you pages are correct. Add automated end-to-end tests that change data and then assert the new value appears where it should, within the agreed window: after a CMS publish, after a user saves a form, after a second user changes shared data. Run them against a production build, because the development server does not cache the same way. For load behaviour on the underlying APIs, our article on performance testing with realistic usage patterns covers how to model traffic.

For example, a SaaS team migrating a React single-page app to Next.js might start with marketing and documentation pages as static with tag revalidation, keep the logged-in dashboard fully dynamic in the first release, and only then introduce caching for shared reference data inside the dashboard once tests prove it stays correct.

Costs, hosting and the risks to plan for

Caching decisions affect hosting bills and operational risk as well as speed.

Cost trade-offs

  • Dynamic rendering costs compute. Every uncached request runs server code and calls your data sources. Making everything dynamic to avoid stale data is safe but can be expensive at scale and puts load on databases and third-party APIs with rate limits.
  • Self-hosting needs a shared cache. By default the Data Cache and Full Route Cache are stored by the Next.js server. If you run several instances behind a load balancer, each may hold its own copy and revalidation on one may not reach the others. Plan a shared cache handler or accept per-instance staleness, and test it.
  • Managed platforms add their own layers. Hosting providers may add edge caching on top of Next.js. Read their documentation and include their behaviour in your freshness tests.

Risk register

RiskImpactMitigation
Implicit caching of a fetch that should be liveWrong prices, stock or status shownExplicit cache options on every fetch; build output review
Personalised response stored in a shared cacheData exposure between usersNo-store for user data, code review checklist, tests with two accounts
Webhook or event missedContent never updatesLogged revalidation, alerting, scheduled fallback revalidation
Framework upgrade changes defaultsSudden load spike or new stalenessExplicit settings now; run freshness and load tests before upgrading
Multi-instance hosting without shared cacheInconsistent pages between requestsShared cache handler or single cache tier, tested before launch

A caching checklist before you ship

Use this as a release gate for any Next.js route that reads data.

  • Every data source has a written freshness class and owner.
  • Every fetch has an explicit cache or revalidate setting; non-fetch data access has documented caching behaviour.
  • User-specific and permission-dependent data never enters the Data Cache, Full Route Cache or a CDN.
  • Every mutation revalidates the right tags or paths, preferably inside a Server Action.
  • CMS and third-party webhooks are logged, alerted on and protected by a secret.
  • The build output matches the intended static and dynamic plan.
  • End-to-end tests confirm changes appear within the agreed window on a production build.
  • Field Core Web Vitals, including INP, are tracked per key template.
  • Editors and support staff know how long updates take and how to force one.
  • An upgrade note lists the caching defaults that will change in Next.js 15 and the tests that must pass first.

If you want an experienced reviewer to walk through your routes and caching plan, or need developers who have done this before, that is the kind of work our Next.js team takes on.

Frequently asked questions

Why does my Next.js page still show old data after we updated it?

Usually because one of the cache layers still holds the old value: the server Data Cache (which persists across deployments), the pre-rendered route, or the browser’s Router Cache. Check whether the fetch is cached, whether the route was built as static, and whether revalidation ran in a Server Action or only in a Route Handler.

Should we just turn caching off everywhere to be safe?

It is safe for correctness but costs speed and server capacity, and puts more load on your databases and APIs. A better approach is to classify data by freshness, cache shared and slow-changing data, and keep personalised or decision-critical data uncached.

Is time-based revalidation enough for prices and stock?

Usually not on its own. It serves stale data to the first request after the window expires while refreshing in the background. Use it for display if a short delay is acceptable, and always re-check price and stock without caching at add-to-cart and checkout.

How does the Next.js 15 release candidate affect us?

It changes fetch requests, GET Route Handlers and Page segments in the client Router Cache to uncached by default. If your app depends on implicit caching, upgrading could increase server load. Making cache settings explicit now reduces that risk.

Can a CDN in front of Next.js leak user data?

Yes, if a response that depends on the logged-in user is stored by a shared cache. Mark user-specific responses private or no-store, keep authenticated pages dynamic, and test with two different accounts.

Sources and methodology

Guidance reflects PoliteTech delivery experience. The external references below informed specific points in this article.

  1. Next.js: Caching in Next.js (version 14 documentation) — accessed 9 November 2026. The four cache layers, default durations, revalidation APIs, Router Cache behaviour and cache interactions
  2. Next.js blog: Next.js 15 RC (23 May 2024) — accessed 9 November 2026. Planned change of caching defaults to uncached and experimental Partial Prerendering
  3. MDN Web Docs: Cache-Control — accessed 9 November 2026. Semantics of private, no-store, no-cache, s-maxage and stale-while-revalidate for CDN caching
  4. web.dev: Interaction to Next Paint becomes a Core Web Vital on March 12 — accessed 9 November 2026. INP replacing FID as a Core Web Vital from 12 March 2024

Are your Next.js pages fast but showing the wrong data?

Tell us how your app renders and where stale data appears. We can review your caching plan or provide Next.js developers to implement it.