← All articles

Time to First Byte: How to Test, Read, and Fix It

Published · 9 min read

Key takeaways

  • A single TTFB number bundles four phases: DNS resolution, TCP connection, TLS handshake, and server wait, and each phase has a different fix.
  • Run curl with -w timing variables three times from a real location and discard the first run, since cold DNS and TLS handshakes inflate it.
  • Target under 200ms server wait on static marketing pages, under 500ms on dashboard endpoints, and 300ms on critical API paths.
  • Fix DNS and TLS first because they are cheap afternoon wins, then add CDN edge caching, and only rewrite backend code if server wait still dominates.
  • A steadily climbing server-wait phase is often the first stage of an outage, so alert on sustained deviation from baseline rather than hard errors alone.

Your time to first byte number only tells you something useful when you split it into DNS, TCP, TLS, and server wait phases, because each phase has a different fix. Run one test from a real location, read the phase breakdown, and you'll know whether to touch DNS, CDN, TLS config, or backend code. This guide shows you how, using tools you already have.

What is time to first byte and where does the clock start and stop?

Time to first byte (TTFB) measures how long a browser waits from the start of navigation to receiving the first byte of the server's response. The timer starts when the browser begins the request and stops when the first byte arrives, not when the page finishes loading. Google's web.dev docs treat TTFB as the baseline metric for page responsiveness, since every other load metric waits on it (web.dev on TTFB).

The four phases hidden inside one number

A single TTFB figure bundles four phases: DNS resolution, TCP connection, TLS handshake, and server wait time. When your TTFB is 900ms, the server itself might only account for 200ms of it. Splitting the number is the only way to know which fix applies, which is the core of our TTFB monitoring guide.

What TTFB does not include

TTFB excludes client-side rendering, asset downloads, and JavaScript execution. A great TTFB with a slow page means the problem is front-end, not server-side. It also excludes redirects in most measurement tools, so a redirect chain can hide latency entirely.

How do you run an accurate time to first byte test from different locations?

curl timing breakdown: the one-command time to first byte check

curl -w gives you TTFB in one line with no browser overhead:

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

Run it three times and discard the first, because cold DNS and TLS handshakes inflate a single run. time_starttransfer is your TTFB; the other three numbers map directly to the phases you'll diagnose later.

Browser DevTools vs synthetic probes

DevTools' Network tab shows Waiting (TTFB) per request, which is useful for a specific page load but runs from your machine only. Synthetic probes hit your app on a schedule from fixed regions, so they catch regressions your laptop never sees. A probe checking every 30 seconds from one region is uptime monitoring; three or more regions is geography-aware monitoring. We cover the full setup in our guide to website availability monitoring.

Why location changes your result

Test sourceWhat it measuresBlind spot
Local curlYour network path to the serverYour ISP, your distance
DevToolsOne real page load, your regionNo history, no other regions
Remote probeFixed region, repeatableOnly the regions you configure

A US East Coast server can post a 120ms TTFB from Virginia and 400ms from Singapore. Test from at least two continents before you trust one number.

What do good and bad TTFB numbers actually mean for a B2B SaaS site?

Use different thresholds per endpoint type. Your marketing site should land under 200 ms server-wait, since it is mostly static and a CDN handles it. App endpoints that render a dashboard should sit under 500 ms. API calls on critical paths (login, checkout, webhooks) deserve the strictest bar: 300 ms, because every downstream integration amplifies your latency.

You can measure each phase yourself with curl's timing variables: time_namelookup for DNS, time_connect for the TCP handshake, time_appconnect for TLS, and time_starttransfer for the full TTFB (curl documentation). Subtract each phase from the last to see where the time goes.

Action triggers: any endpoint whose server-wait phase exceeds 1 second on repeated runs, or whose TTFB swings wildly between probes, needs a fix before you tune anything else. We track server-wait separately from network phases in our probes for exactly this reason; plain URL checks report one blended number and hide which phase regressed. For how TTFB fits into broader availability work, see our uptime monitoring guide.

How do you break down TTFB into DNS, connection, TLS, and server wait time?

Phase thresholds and what they point to

The browser timing breakdown gives you four numbers that should add up to your total TTFB. Read each one against a threshold and route to the matching fix instead of guessing:

  • DNS over ~50ms: slow resolver or missing local caching. Fix with a faster DNS provider or a longer TTL.
  • Connection over ~50ms: too many round trips or a distant server. Fix with connection reuse, keep-alives, or a closer region.
  • TLS over ~100ms: full handshakes on every request. Fix with session resumption, TLS 1.3, and HTTP/2.
  • Server wait over ~200ms: your app or database. This is the only phase your code controls directly.

DNS, connection, and TLS are mostly network problems with network fixes. Server wait is the phase where caching, CDN offload, and backend work pay off, which is the subject of the next section.

Worked example: a 900ms TTFB decomposed

Say your test from a US East location reports 900ms total: DNS 120ms, connection 80ms, TLS 140ms, server wait 560ms. The phases are legible one at a time. DNS at 120ms means your resolver is doing a cold lookup, so check whether you are bouncing between nameservers or skipping caching. Connection at 80ms is acceptable for one round trip. TLS at 140ms suggests a full handshake where resumption should apply, worth a look but not the fire.

The fire is server wait at 560ms, which is 62% of the total and three times the 200ms threshold. Nothing you do to DNS or TLS will move the needle much while the backend takes half a second to answer. That number points at cold cache misses, slow database queries, or synchronous work that belongs in a background job. Fix the server wait first, re-run the same test from the same location, and only then judge the network phases, because the same 560ms of wait will also inflate what your uptime monitor sees. If you are wiring downtime alerts around these checks, the phase breakdown in this guide to reliable downtime alert systems covers how to alert on server wait separately from connection failures, so a slow database page does not page you as an outage.

Which server-side fixes reduce TTFB the most: caching, CDN, or backend optimization?

Rank fixes by the phase that produced your slow number, not by what sounds impressive. Most slow TTFB problems are server wait, but the cheapest wins live in DNS and TLS.

DNS and TLS fixes first (cheapest wins)

If your breakdown shows heavy DNS or TLS time, fix that before touching code. Use a fast DNS provider with low TTLs, enable TLS 1.3 (one round trip instead of two), and enable session resumption so repeat visitors skip the full handshake. TLS 1.3's shorter handshake is documented by MDN in its TLS overview. Both fixes take an afternoon and shave hundreds of milliseconds.

CDN and edge caching

Next, cache what you can at the edge. Static assets, marketing pages, and even HTML with short cache lifetimes can be served from a CDN near the user, collapsing the geographic penalty you saw in multi-location tests. For a B2B SaaS app, caching your status page and app shell at the edge often turns a 900ms TTFB into 100-200ms without touching the backend. Effort: a day, mostly cache-header work.

Backend: the expensive fix you do last

If server wait dominates after edge caching, the slow path is your app: N+1 queries, cold connections, or a bloated framework boot. Add application-level caching for expensive reads, pool database connections, and profile before rewriting. This is weeks of work, so earn it only if the numbers say so.

The same discipline applies to monitoring: probe the critical path, not just the homepage, or you will miss the slowdowns that precede outages (StatusPulse on downtime risks).

How does TTFB relate to Core Web Vitals and uptime monitoring?

TTFB feeds directly into Largest Contentful Paint. Google's guidance treats a server response time under 200 ms as the target, and anything above 600 ms as poor, because slow server wait eats the LCP budget before rendering even starts (web.dev on TTFB). If your LCP is failing in PageSpeed Insights, check the TTFB phase breakdown before touching images or JavaScript.

That same server-wait number doubles as an availability signal. Your monitoring probes and your TTFB test measure the same path, so a TTFB climbing from 200 ms to 4 seconds often means database saturation or a connection-pool exhaustion, not a slow page. This is why probe type matters: a URL check that only verifies HTTP 200 will report "operational" while your API is timing out for customers.

Run protocol-level probes against the endpoints customers actually hit, and alert on response-time thresholds, not just status codes. A tool like UptimeRobot covers basic URL checks; if you need threshold alerts on real endpoints, StatusPulse probes measure full response time, not just reachability.

When is a slow TTFB a symptom of an availability problem rather than a performance one?

A slow TTFB is often the first stage of an outage. A database connection pool filling up, a worker process hanging, or a cache stampede all show up as rising server-wait time before requests start failing outright. If you only alert on hard errors, you find out when customers already see a 5xx. Trend the server-wait phase specifically: a steady climb over minutes is degradation, a single spike is usually noise.

Setting TTFB alert thresholds that survive noise

Alert on sustained deviation, not absolute values. A p95 server-wait above 2x your rolling 7-day baseline for three consecutive probes is a usable starting point; tune from your own history. Run probes from at least two regions so a single network blip doesn't page your on-call. False alarms are how alert fatigue starts, and alert fatigue is how real incidents get missed at 3 AM.

Communicating degradation on your status page

"Degraded performance" exists for exactly this state: up, but slow. Post it when latency crosses your threshold, note the affected component (API, dashboard, database), and update as you investigate. Customers on SLAs will forgive slow; they won't forgive silence.

FAQ

Is a TTFB under 200ms always achievable, or is some server wait unavoidable?

The 200ms target refers to server wait, not total TTFB, and it applies to static or cacheable content. Dynamic pages that render a dashboard or hit a database on every request commonly land in the 200-500ms range. Aim for under 200ms on marketing pages and cached responses, and judge dynamic endpoints against their own baseline rather than a universal number.

Does a CDN guarantee a fast time to first byte for dynamic, logged-in app pages?

No. A CDN only helps when it can serve the response from cache. Logged-in pages with personalized data usually bypass the cache and travel to your origin, so server wait dominates regardless of edge presence. You still gain on DNS, connection, and TLS phases, and you can cache fragments or the app shell, but the backend's response time remains the bottleneck.

How often should I run a time to first byte check, and from how many locations?

For production endpoints, run probes on a schedule, typically every 30 to 60 seconds, from at least two regions on different continents. One region catches regressions but hides geographic problems and single-network blips. For ad-hoc debugging, run curl three times from the affected region and discard the first run, since cold DNS and TLS handshakes inflate it.

Can HTTP/3 or TLS 1.3 reduce TTFB on its own?

They shave the TLS phase, not server wait. TLS 1.3 cuts the handshake to one round trip instead of two, and HTTP/3 removes a separate TCP connection entirely, so first-time visitors save tens to low hundreds of milliseconds. But if your breakdown shows 500ms of server wait, protocol upgrades move the total by a small fraction. Fix the backend phase too.

Why is my TTFB fine locally but slow in production monitoring?

Local tests run from your machine: short distance, warm DNS, warm connections, and often a dev or cached environment. Production probes hit real endpoints from remote regions with cold connections and no local resolver caching. The gap usually means geographic distance, cold caches, or a production database path your laptop never exercises. Compare phase breakdowns from both to find which phase differs.

Monitor it, then tell your customers

10 probes, 3 status pages, forever. No credit card.