Email copiado — support@tuurt.com
Cargando experiencia
nextjs · November 15, 2026 · 7 min

ISR in Next.js: When to Time-Based Revalidate vs. Invalidate On-Demand

We go over the difference between fixed-interval revalidation and on-demand invalidation in Next.js, and the mistake of leaving content that changes through a user action at the mercy of a long interval.

By Tuurt Team

ISR in Next.js: When to Time-Based Revalidate vs. Invalidate On-Demand

Incremental Static Regeneration (ISR) in Next.js promises the best of both worlds: pages served as static assets, with the speed and CDN cost of a site generated at build time, but regenerated in the background without a full redeploy. The problem shows up when a team sets revalidate: 3600 on a page, tests it, sees that it works, and considers content freshness solved. It works right up until someone edits a product from the admin panel and the change does not show up on the public site for the next hour, because time-based ISR has no idea anything changed: it only knows an hour went by.

What time-based revalidate actually does

When a page uses the App Router and sets revalidate on the segment, Next.js serves the cached version on every request until that interval elapses. The first request after the interval expires triggers a background regeneration: the visitor who made that request still gets the old version (stale-while-revalidate), and subsequent requests get the new one.

// app/products/[slug]/page.js
export const revalidate = 3600; // seconds

export default async function ProductPage({ params }) {
  const product = await getProduct(params.slug);
  return <ProductDetail product={product} />;
}

This works well for content that changes on its own at a roughly predictable pace, where nobody expects a change to show up instantly: a blog post that is rarely edited after publishing, a pricing page that changes once a month. An interval of an hour, or a day, is a reasonable approximation of how much staleness is tolerable.

The mistake: relying only on time-based revalidate for content that changes through an action

The mistake happens when the same technique is applied to content that changes because someone did something, not because time passed: an admin edits a product price, a user posts a comment, an editor unpublishes an article. In those cases the change has an exact, known moment -the database write- and relying on a one-hour revalidate means that, in the worst case, the public site shows incorrect information for that entire hour, with no relationship between how serious the change is and how long it takes to show up.

This becomes especially visible with a product price or an order status: it is not a cosmetic detail, it is information a user can act on to decide a purchase. Trusting that the next revalidate cycle will fix it means accepting staleness in exactly the case where being stale is costly and avoidable.

On-demand revalidation: invalidating right when the write happens

Next.js solves this with two functions built for targeted invalidation: revalidatePath and revalidateTag. Instead of waiting for an interval, the same code that performs the write triggers the invalidation at that moment.

// app/api/products/[id]/route.js
import { revalidateTag } from 'next/cache';

export async function PATCH(request, { params }) {
  const changes = await request.json();
  await updateProduct(params.id, changes);

  revalidateTag(`product-${params.id}`);

  return Response.json({ ok: true });
}
// app/products/[slug]/page.js
export default async function ProductPage({ params }) {
  const product = await fetch(`${API_URL}/products/${params.slug}`, {
    next: { tags: [`product-${params.slug}`] },
  }).then(r => r.json());

  return <ProductDetail product={product} />;
}

The tag connects the fetch that generated the cached page with the mutation that invalidates it. The moment the PATCH is confirmed, the next request to that page no longer serves the cached version: Next.js regenerates it. There is no staleness window beyond the normal latency of the write itself.

revalidatePath plays the same role when invalidation is simpler to express by route than by tag -for instance, invalidating the whole /products listing after a catalog change- but it is blunter: it invalidates everything under that route, even if only one product actually changed. revalidateTag is preferable when several pages share the same underlying data and it makes more sense to invalidate by that data than by every route that renders it.

When time-based revalidate is still worth keeping, even with on-demand invalidation

This does not mean replacing revalidate with revalidateTag everywhere. The two techniques solve different problems and coexist fine in the same project. Time-based revalidate is a reasonable safety net even on pages that already have on-demand invalidation: it covers the case of data that changed through a path the code never instrumented -a manual database migration, a change made directly in an external provider that never goes through the endpoint that fires revalidateTag. A 24-hour revalidate as a fallback costs nothing and keeps a silent staleness issue from lasting forever if targeted invalidation fails for some unforeseen reason.

The default combination we use is a long revalidate -hours or a day- as a safety net, plus revalidateTag or revalidatePath fired explicitly from every mutation we know changes that content. Neither one alone covers the full case: revalidate alone leaves avoidable staleness windows, and on-demand invalidation alone leaves the site exposed to any change that happens through a path the code never covered.

What did not work the first time

On an ecommerce catalog we migrated to the App Router, the first ISR implementation used only revalidate: 1800 on the product page, under the assumption that thirty minutes of staleness was acceptable for prices and stock. The operations team started reporting that, after fixing a mis-entered price, the wrong price stayed visible on the site for longer than expected, because that product's clock only reset if someone visited the page right after the previous interval expired; if nobody visited it at that moment, the page kept serving the old version indefinitely until the next visit happened to land after expiration.

The fix was adding revalidateTag to the product-editing endpoint in the admin panel, tagging each product page's fetch with a tag based on its ID. We kept revalidate: 1800 as a safety net, but it stopped being the primary freshness mechanism for the case the business actually cared about. The lesson was not that time-based ISR is wrong, it was that a single revalidate number cannot represent both "how much staleness is tolerable for content that changes on its own" and "how much staleness is tolerable for content that changes because someone edited it"; those are two different questions and they need two different mechanisms.

What we check before signing off on an ISR strategy

Before closing out an ISR implementation, we identify for each page whether its content changes mainly through the passage of time or through an identifiable write action, and we treat each case with the mechanism that fits it instead of applying the same revalidate across the whole project out of habit. We confirm that every mutation that touches cached content explicitly fires revalidateTag or revalidatePath with the correct tag or route, not just in the main edit flow but also in secondary flows like bulk imports or batch edits. And we keep a fallback revalidate even where on-demand invalidation already exists, as a safety net against changes that happen through a path the code does not cover yet.

nextjs isr caching ssr
← Back to blog