DEV Community

Cover image for I Checked Cache-Control on 130 Pages of My Next.js Sites. 67 Are Rendered on Every Request
Posting Dude
Posting Dude

Posted on

I Checked Cache-Control on 130 Pages of My Next.js Sites. 67 Are Rendered on Every Request

I run 13 small sites on Next.js: a few launch boards, a directory, four press sites, a couple of comparison sites and Posting Dude. They all sit on one server with no CDN in front. This morning I wanted to know a boring thing: which of their public pages come out of the Next.js cache, and which get rendered from scratch every time someone (or Googlebot) opens them.

So I took 10 random URLs from each site's sitemap, 130 pages total, and read the response headers with curl.

67 of the 126 pages that loaded were rendered on every request. 4 more returned a 500. Those were all on the same route, shared by four sites.

Bar chart of Cache-Control results for 130 sitemap URLs across 13 Next.js sites: 59 cached, 67 rendered per request, 4 returned 500
10 random sitemap URLs per site, checked with curl on Nov 19, 2026.

How to tell from the outside

You don't need the code for this. Next.js tells you in the headers.

A page served from the cache looks like this (one of my product pages):

cache-control: s-maxage=60, stale-while-revalidate=31535940
x-nextjs-cache: HIT
etag: "ojjhxogi5wba3d"
Enter fullscreen mode Exit fullscreen mode

A page rendered on every request looks like this:

cache-control: private, no-cache, no-store, max-age=0, must-revalidate
Enter fullscreen mode Exit fullscreen mode

No x-nextjs-cache, no etag. The Next.js self-hosting docs explain the private part: when a page uses a dynamic API, Next marks the HTML non-cacheable. A fully prerendered page gets a cacheable header.

The two cached flavours I saw:

  • s-maxage=31536000 on fully static pages (no revalidate at all). 37 pages.
  • s-maxage=60, 300 or 86400 plus a long stale-while-revalidate. That's ISR: serve the cached copy, rebuild in the background once the window passes. 22 pages.

The odd-looking numbers always add up to one year (60 + 31,535,940 = 31,536,000), which is Next's default expire time.

What it costs

Same server, same sites, same box doing the testing. I ran each URL 3 times one after another and took the middle time to first byte.

Dot plot of time to first byte: cached Next.js pages median 0.73 seconds, pages rendered on every request median 1.56 seconds
Median TTFB: 0.73s cached (59 pages) vs 1.56s per-request (67 pages). About 0.5s of every number is TLS setup from my test box.

My box is far from the server, so roughly half a second of each number is just the TLS handshake. Take that off and it's around 0.23s for a cached page vs about a second for a rendered one. The slowest per-request page took 3.6s. web.dev says most sites should aim for a TTFB of 0.8s or less, and every one of my cached pages was under 1s.

The second cost is quieter. The cached pages send an ETag, and when I replayed the request with If-None-Match, 56 of 59 came back 304 Not Modified with no body. The per-request pages have no ETag, so every revisit and every recrawl downloads the full page again.

The part that annoyed me

It's not random. It's by route, and the same kind of page is cached on one site and not on the next:

Page type Cached on Rendered every request on
Product page Aura++ (s-maxage=300), EarlyHunt (s-maxage=60) IndieHunt, MakerHunt, SideHunt
Blog post (/studio) — Aura++, EarlyHunt, IndieHunt, MakerHunt, SideHunt
Founder profile — Aura++, IndieHunt
Category pages — all 4 press sites
Directory listing 3-level URLs on Uno 2-level URLs on Uno

Only two Studio blog posts landed in the random sample, so afterwards I opened one post on each of the five sites with a /studio blog. All five came back private, no-store. The blog posts bug me most. A post changes maybe once a month, and mine get rebuilt on every view.

Also, /projects returned a 500 on all four press sites, every time I tried. The page still renders a title, so it looks fine in a browser. Only the status code says it's broken, which is easy to miss. In my sitemap lastmod audit last week all 390 sampled URLs returned 200, including project pages under /projects/, but the /projects list page itself wasn't in that sample.

Why a page ends up dynamic

I haven't opened every route yet, so I'm not going to guess which line did it on which site. In the App Router, a route usually goes dynamic because something in it, or in a layout above it, reads the request:

  • cookies() or headers(). A "show Login or Dashboard in the navbar" check in the root layout is the classic one, and it makes every page under it dynamic.
  • the searchParams prop on the page
  • fetch(url, { cache: 'no-store' }) or connection()
  • export const dynamic = 'force-dynamic' or revalidate = 0 that someone added to make one bug go away

The quickest way to find it is the route table that next build prints. ○ is static, ƒ is "server-rendered on demand". If a blog post route shows ƒ, start in its layout.

The fix depends on the cause. For a navbar session check, I'd move it into a small client component so the page itself can stay static. For product pages that get votes or comments, ISR with a short revalidate is what Aura++ (300s) and EarlyHunt (60s) already do. The page is at most a few minutes stale, and it gets served from cache.

The script

This is what I ran, cleaned up a bit. It prints one line per URL.

#!/usr/bin/env bash
# cache-audit.sh: sample N URLs from a sitemap and print how each page is cached.
# usage: ./cache-audit.sh https://example.com/sitemap.xml 10
sm="$1"; n="${2:-10}"
curl -s -m 20 "$sm" | grep -o '<loc>[^<]*' | sed 's/<loc>//' | shuf -n "$n" |
while read -r url; do
  h=$(mktemp)
  ttfb=$(curl -s -m 20 -o /dev/null -D "$h" -w '%{time_starttransfer}' \
         -H 'Accept-Encoding: gzip, br' "$url")
  get() { grep -i "^$1:" "$h" | head -1 | cut -d' ' -f2- | tr -d '\r'; }
  code=$(head -1 "$h" | awk '{print $2}')
  cc=$(get cache-control); nx=$(get x-nextjs-cache); et=$(get etag)
  kind=CACHED
  [[ "$cc" == *no-store* || "$cc" == *private* ]] && kind=PER_REQUEST
  [[ "$code" != 200 ]] && kind="STATUS_$code"
  printf '%-12s %5ss  next=%-6s etag=%-3s %s\n' \
    "$kind" "$ttfb" "${nx:--}" "$([ -n "$et" ] && echo yes || echo no)" "$url"
  rm -f "$h"
done
Enter fullscreen mode Exit fullscreen mode

Output from two of my sites while I was writing this:

PER_REQUEST  1.490705s  next=-      etag=no  https://sidehunt.io/project/vouch-local
PER_REQUEST  2.438938s  next=-      etag=no  https://sidehunt.io/launches/project-recala
CACHED       0.740093s  next=HIT    etag=yes https://postingdude.com/blog/seo-for-a-new-saas
CACHED       0.736158s  next=HIT    etag=yes https://postingdude.com/tools/meta-description-checker
Enter fullscreen mode Exit fullscreen mode

Two notes. If you're behind a CDN, check its own header too (cf-cache-status, x-vercel-cache), because the CDN can cache or skip a page whatever Next says. And the -m 20 matters. One request hung during my timing run and I lost a few minutes before I noticed.

What I'd fix first

Nothing is fixed yet. The order I'd go in:

  1. The /projects 500 on the press sites, because a broken status code is worse than a slow page.
  2. Studio blog posts on all five sites to static or ISR. They never needed to be dynamic.
  3. Product pages on IndieHunt, MakerHunt and SideHunt to the same revalidate = 60 that EarlyHunt uses.

Then re-run the same 130-URL check and compare.

If your site might get a launch-day spike, the per-request pages are the ones that fall over first. The SideHunt blog has a guide on getting a side project ready for a traffic spike, and caching the landing page is one of the first steps there. For the browser side (LCP, INP, CLS) there's a separate guide on passing Core Web Vitals on an indie SaaS site in a weekend.

Have you run this on your own Next.js app? I'm curious whether the root-layout cookies() thing is as common as I think, or whether most people hit it some other way.

Top comments (0)