Is Vercel's CDN caching one user's data and showing it to someone else? (Cache-Control on signed-in routes)
By Abbi Labs · Last updated 28 November 2026
Scan your app free and see what a stranger can already read.
Abbi Labs checks your live site from the outside: Supabase tables readable with your public key, secret keys like service_role in the JavaScript, exposed .env and .git files, security headers, CORS, cookie flags and TLS certificate expiry. Read-only. No sign-up for the quick check.
No app handy?
Example result · our deliberately broken demo app
6 issues found: 3 critical, 1 high, 1 medium, 1 low
- Critical: Stripe live secret key in public JavaScript
- Critical: /.env file readable by anyone
- High: Git repository exposed (/.git/HEAD)
The demo's problems are planted on purpose. Paste your own URL above to see yours.
No sign-up. Read-only public-resource and protocol metadata checks. No model prompts or tool execution. Scan only sites you own or are allowed to test.
Run on every deploy or use from Cursor / Claude Code via MCP →
Weekly AI-app security checklist
One short email a week: a practical check for apps built with Supabase, Next.js and AI tools (RLS, leaked keys, headers and more). Unsubscribe anytime.
The bug report usually sounds impossible: "I logged in and saw someone else's name." Nobody touched the database rules. What happened is that a page or API route that returns personal data was told it could be cached, so the CDN kept the first person's response and handed that same copy to the next people who asked for the same URL.
Caching rules below are from Vercel's CDN Cache docs and Purging Vercel CDN Cache. Short version in our tip: is your CDN saving one user's data and showing it to the next?
When Vercel's CDN will cache a response
A function response (an API route, route handler or server-rendered page) gets cached when it sends Cache-Control with s-maxage, or a CDN-Cache-Control / Vercel-CDN-Cache-Control header, and all of these are true:
- The request is
GETorHEAD. - The request has no
Authorizationheader. - The response has no
set-cookieheader. - The response's
Cache-Controldoesn't includeprivate,no-cacheorno-store. - The response has no
Vary: *and noVarynaming a high-cardinality header likeCookie. - The status is 200, 404, 410, 301, 302, 307 or 308, and it's under 10MB.
The second line is the one that catches people. If your app signs users in with a cookie (most Supabase, NextAuth/Auth.js and custom setups do), the browser sends the cookie and no Authorization header. So GET /api/me with s-maxage=60 is cacheable, and for the next 60 seconds every visitor to /api/me in that region can get the first visitor's answer.
How this ends up in AI-built apps
- "Make it faster." Ask an agent to speed up a slow dashboard and adding
s-maxageto the API route is a common answer. It works, until the route is per-user. - One header rule for every route. A
headers()block innext.config.jsor avercel.jsonrule that setss-maxageon/api/(.*)covers/api/meand/api/orderstoo. A header set inside the function overrides the config one, but only if the function sets one. - Copied examples. Caching examples use
public, s-maxage=...because they're showing public content. Pasted into a route that reads the session, they leak. - Supabase calls through your own API. Direct browser calls to Supabase send the user's token in an
Authorizationheader. A Next.js route that reads the session cookie and queries Supabase for the user doesn't, so the CDN sees an ordinary cookie request.
Check it in 2 minutes
1. Read the headers. Sign in, open DevTools > Network, and click a request that returns your own data (/api/me, /api/account, the dashboard page itself). Look at the response headers:
cache-control: public <- Vercel already stripped s-maxage
x-vercel-cache: HIT <- served from the CDN, not your function
age: 42 <- seconds since the CDN stored itDon't rely on seeing s-maxage here. When you set Cache-Control without CDN-Cache-Control, Vercel strips s-maxage and stale-while-revalidate before the response reaches the browser, and Vercel-CDN-Cache-Control is never sent to the browser at all. x-vercel-cache: HIT or STALE on a per-user response is the thing to look for. MISS on the first request can still mean it's being stored, so reload and look again.
2. Two browsers. Sign in as account A in one browser and load the per-user URL. Within the cache time, open the same URL in a private window as account B, or signed out. If you see A's data, the CDN is serving it.
3. Find the header in code. Search the repo for s-maxage, CDN-Cache-Control, Vercel-CDN-Cache-Control and stale-while-revalidate, including next.config.js and vercel.json.
Fix it
Mark every per-user response as private and not stored:
// app/api/me/route.ts
export async function GET() {
const user = await getUserFromSession(); // your session lookup
if (!user) return new Response("Unauthorized", { status: 401 });
return Response.json(
{ id: user.id, email: user.email },
{ headers: { "Cache-Control": "private, no-store" } }
);
}Keep s-maxage only on things that are the same for every visitor: marketing pages, public lists, a pricing JSON. If a config rule sets s-maxage on a whole path like /api/(.*), narrow it to the public routes. Don't try to cache per-user responses with Vary: Cookie. Vercel's CDN won't cache those, and a CDN that does would be one header away from the same leak.
Your 401 and 404 responses matter too. A 404 is cacheable, so an error page with personal data in it (an email address in an error message, say) needs the same header.
Then clear what's already cached
Fixing the header doesn't remove copies that are already stored. Cache keys include the deployment URL, so a fresh production deployment starts with an empty cache for its own responses. To clear the CDN cache for the project from the dashboard, open the project, go to CDN > Caches, click Purge and enter * to purge the entire project. If you run another CDN in front of Vercel, purge it there too.
If personal data was served to the wrong people, treat it as a data exposure: work out which routes and how long they were cached, and decide who needs to be told.
Paste this into your AI builder
Audit caching headers for routes that return per-user data.
1. List every place that sets Cache-Control, CDN-Cache-Control,
Vercel-CDN-Cache-Control, s-maxage or stale-while-revalidate,
including next.config.js headers() and vercel.json.
2. Any route or page that reads the session/cookies or returns data
about the signed-in user must send Cache-Control: private, no-store.
3. Keep s-maxage only on routes whose response is identical for all
visitors. Don't use Vary: Cookie for caching.
4. Show me the final list: route, header, and whether it's per-user.Then do the two-browser test yourself and look for x-vercel-cache on your per-user requests.
What Abbi Labs checks
Honest scope: the free outside scan reads your live site signed out. It doesn't sign in, so it can't see your per-user routes or tell whether the CDN is mixing up users. It reports Supabase tables a stranger can read with your public key, secret keys (including service_role) in your JavaScript, exposed .env and .git files, security headers, CORS, cookie flags and TLS expiry. The caching check on this page is one you run yourself.
FAQ
Does Vercel cache my API routes by default?
Not dynamic function responses. Vercel's CDN caches a function response when it sends Cache-Control with s-maxage (or a CDN-Cache-Control / Vercel-CDN-Cache-Control header) and meets the cacheable criteria. The risk comes from adding that header to a route whose answer depends on who's asking.
Why didn't the Authorization rule protect me?
Vercel won't cache a request that carries an Authorization header. Most web apps sign people in with a cookie instead, and the browser sends the cookie without any Authorization header, so that rule doesn't apply.
Is Cache-Control: private enough?
For the shared CDN, yes: Vercel doesn't cache responses with private, no-cache or no-store. For pages with personal data, private, no-store also stops the browser keeping a copy on a shared computer, so it's the safer default.
Can I use Vary: Cookie to cache per user?
Vercel's CDN doesn't cache a response whose Vary names Cookie at all, because nearly every visitor's cookie is different. If you want per-user caching, do it in your own server code, not in the shared CDN.
Why can't I see s-maxage in DevTools?
If you set Cache-Control without a CDN-Cache-Control header, Vercel strips s-maxage and stale-while-revalidate before the response reaches the browser, and Vercel-CDN-Cache-Control is never sent to the browser. Read x-vercel-cache instead: HIT or STALE means the response came from the CDN.
Does Abbi Labs check this?
No. The free outside scan is signed out, so it can't see your signed-in routes or compare two users' responses. It checks your live site for Supabase tables readable with your public key, secret keys in your JavaScript, exposed .env and .git files, security headers, CORS, cookie flags and TLS expiry. Use the two-browser test on this page for caching.