In web performance, what does Time to First Byte (TTFB) measure for a page navigation, which phases of the request are folded into that single number, and why does a high TTFB drag the paint metrics with it?
answer
- measured before any pixel exists
- one number, several unrelated phases
- redirects and handshakes hide inside
- a floor under every paint
- diagnostic, not a Core Web Vital
basics
~20 sTTFB measures the time from the start of a navigation until the first byte of the main document's response arrives. It folds in redirects, DNS, connection setup, TLS and server processing, so every paint metric can only begin after it.
solid answer
~50 sTTFB is the elapsed time from the moment the browser starts a navigation to the moment the first byte of the main HTML response comes back. It is a **composite**: any redirects, service worker startup, DNS resolution, TCP connection, TLS negotiation, sending the request, the server's own think time, and the network trip back are all inside that one number. That is why it behaves like a floor — the parser has nothing to work with until the first byte lands, so First Contentful Paint and LCP are pushed out roughly one-for-one by TTFB. Current guidance treats about 800ms as good and over 1.8s as poor at the 75th percentile, but TTFB is a diagnostic metric, not a Core Web Vital. When it is bad, the useful move is to split it: connection-phase cost points at distance and lack of edge termination, a long server phase points at the application, and a step-shaped TTFB usually means a redirect chain.
go deeper
Be able to say plainly that TTFB is the wait for the first byte of the HTML, that it happens before anything is drawn, and that a big TTFB makes every later metric worse.
Explain the phases folded into the number — redirects, DNS, connection, TLS, server time — and show how you would split a bad TTFB into connection cost versus server cost before proposing a fix.
Demonstrate that you use TTFB to decide whether a problem is even a front-end problem. Talk about redirect chains, edge termination, cold starts and streaming, and about reading the field distribution rather than one lab number.
Own the tradeoff between caching HTML at the edge and serving it personalized from the origin, and the cost of the streaming or edge-rendering architecture that buys a low TTFB. Be ready to say when TTFB is not the constraint worth spending engineering time on.
## What the metric actually is Time to First Byte is the interval between the browser beginning a navigation — the moment it commits to fetching a new document — and the arrival of the **first byte of that document's response**. It is not the first byte of any resource, and it is not the first pixel. It is one number describing the entire round trip for the HTML. TTFB is not one of the Core Web Vitals. It is a *supporting* or *diagnostic* metric: nobody ships a product because TTFB is green, but when LCP is bad, TTFB is the first place you look to decide whether the problem is even in the browser at all. ## Everything that hides inside the number A navigation's TTFB is a sum of phases that have nothing to do with each other: - **Redirects.** Each redirect is a complete request and response of its own, and its time is charged to TTFB. A chain like `http://example.com` → `https://example.com` → `https://www.example.com` → `https://www.example.com/en/` costs three extra round trips before the real document is even requested. - **Service worker startup.** If a service worker controls the navigation, the time to boot it and run its fetch handler counts. - **DNS lookup**, on a cold resolver cache. - **TCP connection** (or QUIC handshake) and **TLS negotiation**. On a new origin over a long distance these are multiple round trips before a single application byte moves. - **Request send + server think time.** The application's own work: routing, authentication, database queries, template rendering. - **The first byte travelling back** across the network. The practical consequence is that "TTFB is 1.4s" tells you almost nothing on its own. Two sites with identical TTFB can need completely opposite fixes — one is spending 1.2s in the database, the other is spending 1.2s on connection setup from another continent. ## Why it is a floor under everything else The HTML parser cannot start until bytes arrive. No stylesheet is discovered, no script is queued, no image URL is known. So First Contentful Paint, Largest Contentful Paint and every other load metric sit strictly *after* TTFB on the timeline. If you shave 400ms off TTFB and change nothing else, the paints typically move about 400ms earlier too — TTFB improvements propagate almost one-for-one, which is what makes them unusually high-leverage compared with micro-optimizing the front end. The converse is the more important interview point: if TTFB is 2.5s, no amount of image optimization, preloading or code splitting will produce a good LCP. The budget is already spent. ## Reading a bad TTFB The diagnosis is a decomposition, not a single answer: - **Connection phases dominate** → the user is far from the origin, or connections are not being reused. This is the case edge termination and connection reuse address, because the expensive handshake happens close to the user. - **Server phase dominates** → it is a backend problem: an uncached query, a slow upstream, a cold serverless instance. No front-end change will help. - **Time appears in discrete steps** → redirects. Count them and collapse them; canonical host and scheme should be one hop at most. - **First byte is fine but the page still feels slow** → the response is streaming slowly. TTFB only describes the *first* byte; a server that flushes a `<head>` immediately and then blocks for a second on data has an excellent TTFB and a poor experience. ## Where TTFB misleads Because TTFB is measured per navigation, several situations distort it. A back/forward-cache restore or a service-worker-served response can produce a near-zero TTFB that says nothing about how fast the site is for a first-time visitor. Client-side route changes in a single-page app are not navigations at all, so they contribute no TTFB — a slow SPA can post excellent TTFB numbers forever. And field TTFB is dominated by the *distribution* of your users' networks and locations, so a value that looks bad may be mostly last-mile latency you do not control. A useful mental model: TTFB is the cost of *getting permission to start*. It is the only metric on the page that is largely decided before the browser has drawn anything, and it is the only one a purely front-end change usually cannot fix. ## What actually moves it Serving the HTML from a cache close to the user, cutting redirect chains, reducing server work (query caching, avoiding cold starts), and streaming the response so the first byte is not held hostage to the slowest data fetch. Informational `103 Early Hints` responses are worth knowing about here as well — they let the browser start fetching critical subresources during the server's think time, which does not shorten the document's TTFB but stops that time from being pure waste.
- A site's TTFB looks fine for returning visitors but is terrible for first-time visitors from a distant region. What does that pattern point at?Connection setup, not server work. Returning visitors reuse warm connections and warm DNS, so their TTFB is mostly server think time. First-time distant visitors pay DNS, TCP and TLS round trips scaled by distance before the request is even sent. The fix is terminating connections closer to the user, not optimizing the application.
- A server flushes the document `<head>` immediately and then waits a second for data before sending the rest. What does that do to TTFB versus the user's experience?TTFB looks excellent, because the first byte left the server almost immediately — TTFB only describes the first byte, not the last. The user still waits, though the wait is more productive: the browser can parse the head, discover stylesheets and scripts, and start those fetches during the pause. The number improves more than the experience does.
- Why can a page report a near-zero TTFB that tells you nothing about the site's speed?Because some navigations do not touch the network. A back/forward-cache restore or a response served straight from a service worker or the HTTP cache produces a first byte almost instantly. Field data mixing those navigations with cold ones will flatter the aggregate, which is why you look at the distribution rather than the mean.
saying these in an interview costs you the question
- Says TTFB only measures how long the server took
- Calls TTFB a Core Web Vital
- Ignores redirect chains when TTFB is high
- Assumes a CDN fixes TTFB even for uncached HTML
- Confuses the first byte with the first paint