What makes up TTFB
- Redirects (e.g. HTTP → HTTPS, non-www → www).
- DNS resolution and TCP + TLS connection setup.
- Server response generation time (database, rendering, APIs).
- Network distance between the user and the server.
How to reduce TTFB
The most common improvements are caching full HTML responses (CDN, reverse proxy), generating pages ahead of time (SSG/ISR instead of on-demand rendering), optimizing database queries, HTTP/2 or HTTP/3, and serving content from locations close to users. Apply HTML caching only after defining personalization and invalidation rules.
Example
Simplified scenario without redirects or queueing: 12 + 48 + 620 = 680 ms until the first byte; content download comes later. Waiting includes network latency and server work. The cache header below is only for public, unpersonalized responses; do not copy it to accounts, payments or responses containing user data.
DNS lookup: 12 ms
TCP + TLS: 48 ms
Waiting (TTFB): 620 ms ← network + server work
Content download: 35 ms
─────────────────────────
Total to 1st byte: 680 msCache-Control: public, max-age=60, s-maxage=3600, stale-while-revalidate=86400For navigation, TTFB runs from navigation start to response start, for example responseStart − startTime in Navigation Timing. It can include redirects, DNS, connection setup, network latency and server work. DevTools Waiting (TTFB) starts later and does not cover the same interval.
A good TTFB is roughly 800 ms or less. This is a practical guideline, not a guarantee of good LCP, because rendering, assets and network conditions also matter.
Start with HTML caching on a CDN, fewer redirects, faster server queries and pre-generated pages. Measure DNS, connection setup and server waiting time separately.