# Why pages that set cookies must not be cached
*articles*
This article explains how to keep pages that change with a cookie out of shared caches. It covers what `Cache-Control: private, no-store` means, when V17 in vuln reports a finding (reference, priority 1) and where that check stops, and how to fix it on a CDN and behind a login. It also includes what we measured on our own site on 1 December 2026.


You sign in, and the page shows someone else's name. The cause of that kind of accident is the cache setting on pages that hand back a cookie (a small note a site leaves in your browser). For this article I measured my own site's response headers to see whether the setting was needed.

The short answer: **do not let a shared cache store pages whose contents change with a cookie.** Pages behind a login should return `Cache-Control: private, no-store`. That alone avoids showing one visitor another visitor's page.

## What a cache is

Picture a restaurant that keeps food ready to serve. Instead of cooking every dish from scratch on each order, it serves from the pre-made batch and gets the food out faster. A cache works the same way: it stores a response that was built once and reuses it for the next visitor.

If you also keep ready-made portions of dishes that differ per guest, though, the neighbouring table's plate gets carried out. A cache lives either inside the browser or in a shared place such as a CDN (a cache that serves many visitors). Accidents happen with the shared kind.

## Why it concerns you

AI-built apps are often published through a CDN such as Cloudflare, Netlify, or Vercel. A CDN stores responses so it can answer requests to the same URL quickly.

Pages behind a login usually keep the same URL and change their contents with a cookie. If the server says "this page may be cached publicly", the CDN stores the first visitor's HTML. The next visitor gets that stored HTML.

The official pages are here.

- [MDN's official Cache-Control documentation (English)](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control)
- [Cloudflare's official documentation on cache behaviour (English)](https://developers.cloudflare.com/cache/concepts/cache-behavior/)
- [Netlify's official documentation on headers (English)](https://docs.netlify.com/routing/headers/)
- [Vercel's official documentation on headers (English)](https://vercel.com/docs/headers)

It is not common, but when it happens the impact is large. A name, an email address, or an order history shows up for someone else. The cause is a single header, so the check is easy.

## What "publicly cacheable" means

The server uses a header called `Cache-Control` to say whether a response may be stored and who may receive it. Its value is a combination of words.

- `public`: a shared cache may store it
- `private`: the browser may store it, but a shared cache may not
- `no-store`: nothing may store it
- `max-age=600`: for example, it may be reused for 600 seconds
- `s-maxage=600`: for example, a shared cache may reuse it for 600 seconds

A response with `public` and `max-age` (or `s-maxage`) can be stored by the CDN. When a `Set-Cookie` header (the header that tells the browser to keep a cookie) sits on the same response, different visitors' HTML lands in that shared storage.

`no-cache` does not mean "do not store". It means "store it, but check with the server before every use". **`no-store` is what stops storage itself.** The names and meanings are easy to mix up, so be careful here.

## How vuln shows it

In vuln ([a free check for a public URL](/en/vuln)), this setting appears as one line, V17.

- V17 Caching (reference) (area: Headers, priority 1)

V17 looks at the response when the top page is opened normally (GET). It only reports a finding when all four of these are true.

- `Cache-Control` contains `public`
- it contains neither `no-store` nor `private`
- `max-age` or `s-maxage` is 1 or more (judged on the value written first)
- `Set-Cookie` is present and `Vary` does not contain `Cookie`

The result in that case is "Check" (severity low, medium confidence, inferred). It does not see whether anything was actually stored; it infers from the combination of headers.

V17's importance is 1 (reference), and it does not look at pages behind a login. **A pass means "that combination was not present on the top page".**

## What we measured on this site

On 1 December 2026 I checked the response headers with `curl -sS -D - -o /dev/null https://ismyappok.com`. The result was `HTTP/2 200`, and there was no `cache-control`, no `set-cookie`, and no `vary`.

The pages this site publishes now have no login, and it does not return HTML that changes per visitor. Saying nothing is correct here, and V17 passes. No header needs to be added.

If your site does have a login, saying nothing leaves the behaviour to the CDN's defaults. Defaults differ between CDNs and hosts, so **set `private, no-store` yourself on responses behind the login.**

## How to fix it

Your job is to return `Cache-Control: private, no-store` wherever you return HTML behind a login. The per-item steps are on [Caching of personalised pages](/en/checks/cache-with-cookies).

In Next.js, add the response header to the target path with `headers()` in `next.config.js`, or set it in middleware. On static hosting, write only the target paths in the header configuration file for Netlify or Vercel. The official steps are here.

- [Next.js's official headers documentation (English)](https://nextjs.org/docs/app/api-reference/config/next-config-js/headers)
- [MDN's official Vary documentation (English)](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Vary)
- [Cloudflare's official documentation on cache behaviour (English)](https://developers.cloudflare.com/cache/concepts/cache-behavior/)
- [Netlify's official documentation on headers (English)](https://docs.netlify.com/routing/headers/)
- [Vercel's official documentation on headers (English)](https://vercel.com/docs/headers)

It also helps to put a rule on the CDN side that bypasses the cache when a cookie is present. On Cloudflare that is Cache Rules (the feature that sets conditions for caching); on Netlify or Vercel it is the header configuration or the function's response.

If you really must store the response in a shared cache, add `Vary: Cookie` and stop returning `Set-Cookie`. Each cookie then gets its own storage, though, and the cache rarely hits (you keep rebuilding instead of reusing what was stored). For pages behind a login, not storing them is the simpler choice.

## What caching does not prevent

A response with no `Set-Cookie` can still change with a cookie. V17 only uses `Set-Cookie` as a clue, so **do not let HTML behind a login be stored even when no cookie header appears.**

`private` keeps a shared cache from storing the response, but the visitor's browser may still store it. On a shared computer, the back button can show the previous screen. On logout, consider moving the visitor to a `no-store` screen.

Cache settings do not prevent XSS (injecting a malicious script into a page) or CSRF (making a visitor's browser act from another site). Pair them with the other measures.

## Wrapping up

Start by [running vuln](/en/vuln) and looking at the V17 line. If your site has no login, nothing in this article applies. If it does, start by adding one line, `Cache-Control: private, no-store`, to responses behind the login.

The fixes are collected on these pages.

- [Caching of personalised pages](/en/checks/cache-with-cookies)
- [Cookie attributes](/en/checks/cookie-attributes)
- [Security headers](/en/checks/security-headers)

You can check display and links before launch with [audit (a free display check, no login)](/en/audit) as well.

A single header preventing an accident this heavy seems worth checking first whenever you build a login screen.

This article is based on checking our own site's responses. We did not scan anyone else's site for it. The numbers are implementation conditions and illustrative examples; the only measurements are the ones with the date and method given in the text.

## Check your own site
Enter a URL and see what is missing before launch. Free, and no login required.
[Run the free check](https://ismyappok.com/en/audit)