IAnswerable

Do You Need a CDN or Just Better Caching

13 Oct 2026

Most sites that think they need a CDN actually have a caching problem. A CDN moves bytes closer to the user. Caching avoids regenerating those bytes in the first place. If your origin is slow because it recomputes the same response on every request, a CDN just hides that latency for cached edges and exposes it in full on every miss.

Find out which problem you have

Check where the time actually goes.

curl -o /dev/null -s -w "dns:%{time_namelookup} connect:%{time_connect} ttfb:%{time_starttransfer} total:%{time_total}\n" https://example.com/

When better caching is the fix

Fix this with HTTP caching headers first, before reaching for infrastructure:

Cache-Control: public, max-age=300, stale-while-revalidate=60

stale-while-revalidate lets you serve a slightly stale response instantly while refreshing it in the background. That alone kills most tail latency on read-heavy endpoints.

If you’re behind a reverse proxy already (nginx, Varnish, or your cloud LB), turn on response caching there before adding a new vendor.

When you actually need a CDN

The trap: adding a CDN without fixing cache headers

If you drop Cloudflare or Fastly in front of an origin with no Cache-Control header, most CDNs default to not caching HTML at all. You pay for the extra network hop and get zero caching benefit. You’ll see this in the CDN’s own analytics: cache hit ratio near 0% on your main routes.

Symptom Real cause Fix
Slow TTFB globally No CDN, distant origin Add CDN for static/cacheable routes
Slow TTFB even from nearby test Slow app/DB Fix caching or query, not distance
CDN added, no speedup Missing Cache-Control Set headers before or alongside CDN
Fast first load, slow repeat No client caching Add max-age for assets

The order that works

  1. Add correct Cache-Control headers at your origin or reverse proxy.
  2. Measure your actual cache hit ratio.
  3. Only then add a CDN, and only for the routes that benefit — static assets and cacheable pages, not personalized or write-heavy endpoints.

A CDN in front of a badly-cached origin is a more expensive way to serve the same slow page.