Reference guide · performance · Published 2026-08-16 · 3 min read

CDN and Time To First Byte

CDN and TTFB: how the edge's cache and connection decides the TTFB you measure, and how to measure origin TTFB separately.

What TTFB means when a CDN is in front

Time To First Byte (TTFB) is the interval from the request to the first byte of the response. Behind a CDN that interval has up to three legs:

  1. The edge answers. If the CDN has the response cached, the edge can reply without contacting the origin at all, and TTFB is the round trip to the CDN plus the edge's local read time.
  2. The CDN fetches from origin. On a cache miss, the edge requests the origin and relays the first byte once it arrives, which adds the origin's processing time to the edge round trip.
  3. Connection setup. TLS and TCP handshakes plus any connection reuse sit in front of the first content byte. A CDN terminates TLS close to the user, which is usually faster than the origin's own handshake from the same location.

So "my TTFB is 300 ms" behind a CDN does not tell you whether the origin is fast or the edge is; the split matters for tuning. The TTFB reduction guide covers the origin-side levers; this article covers the perspective change.

The cache split

ResponseTTFB you measureWhat it actually proves
Edge cache hit (cf-cache-status: HIT)Edge latency + local readThe edge has the copy
Edge cache missOrigin time + edge relayThe origin really answered
Dynamic / no-cache pageOrigin time + edge relaySimilar to miss
Asset (immutable)Edge round tripCould be 5 ms to a nearby edge

The practical tool: measure with and without the CDN. A curl to the origin IP (or a non-CDN URL) gives the pure origin TTFB; a curl to the public domain gives the merged number. The difference is the edge's contribution.

The interaction with cacheability

The CDN changes TTFB mostly by making repeat requests for cacheable content cheap. For dynamic pages that must hit the origin every time, the edge adds a hop unless you enable surrogate-key/stale-while-revalidate caching (the Cloudflare cache TTL article covers the TTL knobs). So:

Measuring both numbers

curl -w "connect: %{time_connect} ttfb: %{time_starttransfer}\n" -o /dev/null https://example.com
curl -s -o /dev/null -H "Host: example.com" -w "origin ttfb: %{time_starttransfer}\n" https://203.0.113.50/ -k

The -w timing with the Host header (and -k for the cert mismatch on the raw IP) gives the origin number; the first line gives the edge number. Compare them, and use cf-cache-status to bucket the sample.

When not to chase it

TTFB behind a CDN is only a meaningful target when:

The web performance audit places TTFB in the full waterfall so the CDN number is not mistaken for the whole story.

Need a website built, fixed, optimised, migrated or replaced?

This technical resource is written by CSMBAC, a small design and development studio. If you would rather hand the problem to a professional, the website service page explains how we build enquiry-ready websites.

Explore website services