Glossary Term
TTFB (Time to First Byte)
TTFB is the time from starting a request until the first byte of the response arrives. Learn what it includes, how to measure it and what usually inflates it.
On this page
TL;DR: TTFB is how long the browser waits until the first byte of the response shows up. For a page load it counts redirects, DNS, TCP, TLS and the server’s think time, not only your backend.
Time to First Byte (TTFB) is the time from the start of a request until the first byte of the response is received. In the Navigation Timing API, for a page load it is responseStart - startTime, so everything before the server starts replying is counted: redirects, DNS lookup, TCP and TLS setup, the request itself, and the server’s processing time.
Measuring it
curl -o /dev/null -s -w 'dns=%{time_namelookup} connect=%{time_connect} tls=%{time_appconnect} ttfb=%{time_starttransfer} total=%{time_total}\n' https://example.com/
time_starttransfer is the time to the first byte, measured from the start of the curl run. Subtract time_appconnect to get roughly the server’s wait. In the browser:
const [nav] = performance.getEntriesByType('navigation')
console.log('TTFB ms:', nav.responseStart)
Non-obvious facts
- Two definitions in circulation. DevTools’ “Waiting for server response” is only the wait after the request is sent. Field data (CrUX, RUM, PageSpeed) counts from navigation start. Compare like with like before declaring a regression.
- Redirects count. An
httptohttpshop or awwwredirect adds a full round trip, and sometimes a second TLS handshake, before the first byte of the real page. - Streaming changes what “first byte” means. A server that flushes headers or a shell early gets a low TTFB even if the body takes seconds. Low TTFB alone does not mean the page is fast.
- You can see where the time went. Have the server emit a
Server-Timingheader (Server-Timing: db;dur=53, app;dur=47) and it appears in DevTools and in the Performance API. - Common inflators. A cold cache or cache bypass at the CDN, a slow database query, a serverless cold start, a distant origin, and a missing connection reuse to the upstream.
Go deeper
Frequently asked questions
What is TTFB?
Time to First Byte is the time between the start of a request and the arrival of the first byte of the response. For a page navigation it includes redirects, DNS, connection setup, TLS and the server wait.
What is a good TTFB?
web.dev suggests 0.8 seconds or less at the 75th percentile is good and more than 1.8 seconds is poor. It is a diagnostic metric, not one of the Core Web Vitals.
Why is the TTFB in DevTools smaller than in PageSpeed or RUM data?
The DevTools Network panel shows only the "Waiting for server response" phase. Field tools measure from navigation start, so they include redirects, DNS, TCP and TLS.
Does a CDN lower TTFB?
Yes for cacheable responses, because the edge answers without contacting the origin and the TLS connection is short. It does not help uncached dynamic responses that must reach a slow origin.
Sources
Related
CDN (Content Delivery Network)
A CDN is a network of edge servers that cache and serve responses near users. See how cache hits show up in headers and what CDNs do not cache by default.
Server-Timing Header
Learn how the Server-Timing header communicates server-side performance metrics to browsers. Analyze backend timing, database queries, and optimize performance.
Cache-Control Header: Directives, Examples and CDN Behavior
Cache-Control directives explained: max-age, no-cache vs no-store, s-maxage, stale-while-revalidate, immutable, with nginx, Cloudflare and Next.js examples.
Request and Response Lifecycle
Learn how HTTP requests travel from browser to server and back. Understand DNS resolution, TCP connections, request/response flow, and the complete lifecycle.