Vercel ISR Cache Stampede Took Down Our Marketing Site: The Fix
A Black Friday traffic spike turned our Next.js ISR site into a cache stampede that hammered our CMS. Here's what went wrong, what Vercel's docs don't tell you, and how we rebuilt the revalidation strategy.
A product launch pushed roughly 40x our normal traffic through a Next.js marketing site on Vercel. Within ninety seconds, our headless CMS started returning 503s, pages went blank, and our on-call pager lit up. The culprit wasn't traffic volume — it was Incremental Static Regeneration doing exactly what the docs say it does, just not what we assumed it did.
This is the postmortem, the mental model we had wrong, and the revalidation pattern we now use on every ISR site we ship.
The setup
The site was a fairly typical Next.js 14 App Router build deployed to Vercel, pulling content from a headless CMS (Sanity, in this case, though the pattern applies equally to Contentful, Strapi, or Payload). Around 300 pages: landing pages, a blog, a resource library, and a product catalog.
The revalidation config looked like this:
// app/[slug]/page.tsx
export const revalidate = 60; // seconds
export default async function Page({ params }) {
const content = await fetchFromCMS(params.slug);
return <PageRenderer content={content} />;
}
Sixty-second revalidation. Reasonable, we thought. Content editors wanted changes to appear within a minute or two, and ISR is supposed to be the "serve stale, revalidate in the background" pattern. What could go wrong?
What we assumed ISR did
Our mental model: a single page gets requested, Vercel serves the cached version, and one background regeneration fires off to refresh the cache. Subsequent requests during that regeneration window also get the stale version. Classic stale-while-revalidate.
This is mostly true for a single page on a single edge node. It is not true across Vercel's global edge network under load.
What actually happened
At 10:03 UTC, the launch announcement went out. Traffic hit simultaneously from dozens of regions. Each edge region maintains its own cache. Each region independently decided its cached pages were stale. Each region independently fired revalidation requests back to the origin function, which in turn fetched from the CMS.
For a hot page like / or /pricing, this meant somewhere between 15 and 25 concurrent revalidation requests hitting the CMS per revalidation cycle, every 60 seconds. Multiply by the top 20 most-visited pages and the CMS was fielding several hundred concurrent authenticated API calls on a service tier that comfortably handled maybe 50.
The CMS started rate-limiting us. Revalidations failed. Vercel served stale content (good) but also kept retrying failed revalidations (less good). Some pages fell out of cache entirely on cold edge nodes and had to be generated on demand — against a CMS that was now effectively down.
The symptom that confused us
For the first ten minutes, we thought it was a CMS problem. Our Sentry dashboard showed a flood of 5xx errors originating from fetchFromCMS. We paged the CMS vendor. They came back twenty minutes later saying our account was hitting published rate limits.
Published rate limits we'd been nowhere near in staging load tests, because our load tests hit the already-warm Vercel edge cache and never actually exercised the revalidation path at scale.
Load-testing a site in front of ISR without forcing cache misses tests your CDN, not your application. We now treat this as a standing rule in pre-launch checklists.
The fix, in three layers
There isn't one silver bullet here. We ended up layering three changes, and each one matters independently.
Layer 1: switch to on-demand revalidation
Time-based revalidation is the wrong default for a content site where editors already know when something changes. We moved to on-demand revalidation triggered by CMS webhooks:
// app/api/revalidate/route.ts
import { revalidateTag, revalidatePath } from 'next/cache';
import { NextRequest, NextResponse } from 'next/server';
export async function POST(req: NextRequest) {
const secret = req.headers.get('x-webhook-secret');
if (secret !== process.env.REVALIDATE_SECRET) {
return NextResponse.json({ ok: false }, { status: 401 });
}
const body = await req.json();
const { documentType, slug } = body;
// Revalidate by tag so related pages update together
revalidateTag(`content:${documentType}`);
if (slug) revalidatePath(`/${slug}`);
return NextResponse.json({ revalidated: true, now: Date.now() });
}
And on the page itself, we switched to tag-based caching with a long or infinite revalidation window:
async function fetchFromCMS(slug: string) {
const res = await fetch(`${CMS_URL}/pages/${slug}`, {
headers: { Authorization: `Bearer ${CMS_TOKEN}` },
next: { tags: [`content:page`, `page:${slug}`] },
});
return res.json();
}
export const revalidate = false; // no time-based revalidation
This flipped the problem on its head. Instead of 300 pages revalidating on independent 60-second timers across every edge region, nothing revalidated until a human actually changed something — at which point a single webhook invalidated exactly the affected tags.
Layer 2: a revalidation queue at the origin
For the handful of pages we couldn't move to pure on-demand (a stock ticker widget, a currency exchange display), we kept time-based revalidation but moved the actual data fetch behind a single origin-side cache with a short lock.
The pattern: the Next.js page always reads from an internal API route. That API route uses a Vercel KV (Upstash Redis) key with a short TTL and a lock key to ensure only one request at a time actually touches the slow upstream.
// app/api/stock-data/route.ts
import { kv } from '@vercel/kv';
export async function GET() {
const cached = await kv.get('stock-data');
if (cached) return Response.json(cached);
// Try to acquire a lock; if someone else has it, return stale or wait briefly
const gotLock = await kv.set('stock-data:lock', '1', { nx: true, ex: 10 });
if (!gotLock) {
const stale = await kv.get('stock-data:stale');
return Response.json(stale ?? { status: 'warming' });
}
try {
const fresh = await fetchExpensiveUpstream();
await kv.set('stock-data', fresh, { ex: 60 });
await kv.set('stock-data:stale', fresh, { ex: 600 });
return Response.json(fresh);
} finally {
await kv.del('stock-data:lock');
}
}
Now all N edge regions revalidating simultaneously funnel through a single lock. At most one upstream call per cache window, regardless of how many regions are asking.
Layer 3: make failure visible before it matters
We were flying blind on revalidation health. Vercel's function logs show you individual invocations but not "we tried to revalidate /pricing 47 times in the last minute and 38 failed."
We added structured logging around every CMS fetch with two fields: fetch.purpose (either render or revalidate) and fetch.outcome. Piped those into our existing log pipeline and built a simple dashboard: revalidation success rate per route, and upstream latency p95 for the revalidation path specifically.
If you're on Vercel and using Sentry, their performance tooling can capture this if you instrument the fetch wrapper. We also added a synthetic that forces a cache miss on a canary page every five minutes and alerts if the cold-path latency exceeds a threshold — the one test staging never ran.
What we'd watch out for
A few things worth flagging if you're about to set revalidate on an App Router page and move on:
- Edge cache is per-region, not global. Your 60-second revalidate is 60-seconds-per-region, and under global traffic that multiplies.
generateStaticParamswith ISR is a trap at scale. Pre-generating 10,000 pages means 10,000 pages all eligible for revalidation. PreferdynamicParams: truewith on-demand revalidation for long-tail content.- Webhook delivery isn't guaranteed. Retries, dead-letter queues, and a nightly reconciliation job that force-revalidates known-stale tags will save you.
- Preview and production should share the same pattern. We've seen teams use on-demand in prod and time-based in preview, then ship a time-based config to prod by accident during a merge.
Where we'd start
If you're running a Next.js site on Vercel with time-based ISR against a CMS or any rate-limited upstream, do three things this week:
- Look at your top ten pages by traffic. Count how many unique edge regions have served them in the last 24 hours (Vercel's analytics show this). Multiply by your revalidation frequency. That's your upstream load floor.
- Add structured logging that distinguishes render fetches from revalidation fetches. You can't fix what you can't see.
- Pick one high-traffic route and move it to on-demand revalidation with webhook triggers. Measure the upstream call rate before and after. The number will change your mind about what the default should be.
If you want a second pair of eyes on a Next.js or Vercel architecture before it hits real traffic, that's the kind of work our DevOps and cloud team does regularly. Postmortems are cheaper when they happen in review.
Want a team like ours?
72Technologies builds production software for the kind of teams who actually read this blog.
Start a projectKeep reading
AWS NAT Gateway Charges Ate 18% of Our Bill: How We Found and Fixed It
A quiet NAT Gateway was quietly draining our AWS budget through S3 and ECR traffic that never needed to leave the VPC. Here's how we traced it and what we changed.
Vercel Edge Middleware Hit 1MB: How We Cut It Back Under the Limit
Our Vercel middleware bundle quietly ballooned past the 1MB edge limit and broke a Friday deploy. Here's what was actually in it, what we ripped out, and the patterns we now enforce in CI.
GCP Cloud Run vs AWS Fargate for Bursty Workloads: A Cost and Cold-Start Breakdown
We ran the same containerized API on Cloud Run and Fargate for six months. Here's what the bills, cold starts, and scaling behavior actually looked like when traffic went sideways.
