Skip to content

Measuring WordPress TTFB across the full request lifecycle

A single TTFB number hides where time is actually spent. Here is how to break a WordPress request into its real phases — DNS, TLS, edge, network, PHP, DB.

“TTFB is 2 seconds” is not a useful sentence to act on. Time-to-first-byte is the sum of every layer a request touches between client and first byte — DNS, TCP, TLS, edge processing, network to origin, web server queueing, PHP, database, and back. Tuning the wrong layer is the most common failure mode in WordPress performance work. Splitting TTFB into phases is how you stop doing that.

What’s actually happening

A WordPress request passes through, in rough order: DNS resolution; TCP handshake; TLS handshake; HTTP request to the edge (Cloudflare); a cache decision at the edge; on cache miss, a connection to the origin; nginx or Apache accepting; PHP-FPM picking up a worker; WordPress bootstrap; plugin and theme init; the request handler (WP_Query, template, REST controller); database queries; rendering; and finally the response heading back. Each phase has its own latency profile, and on different days the bottleneck lives in different places.

A single composite number cannot tell you which one. Measuring each phase separately can.

How to verify

The simplest first measurement is curl with timing output:

curl -w '@-' -o /dev/null -s https://example.com/some-article/ <<'FMT'
namelookup:  %{time_namelookup}s
connect:     %{time_connect}s
appconnect:  %{time_appconnect}s
pretransfer: %{time_pretransfer}s
starttransfer: %{time_starttransfer}s
total:       %{time_total}s
FMT

namelookup is DNS. connect - namelookup is TCP. appconnect - connect is TLS. starttransfer - pretransfer is the part WordPress and the edge own together. If starttransfer is the dominant cost, the problem is server-side. If TLS is dominant, the origin’s TLS termination or session resumption is wrong. If DNS is dominant, the resolver chain is misconfigured.

To split server-side time further, enable Query Monitor on a non-production environment, or use the SAVEQUERIES constant plus a small mu-plugin to log $wpdb->queries totals. Compare PHP wall time to total database time. If PHP is the dominant cost minus database, profiling with Xdebug or Tideways is the next step. If database is the dominant cost, the slow log of MySQL is.

At the edge, Cloudflare’s cf-ray and timing in Server-Timing headers tells you whether the edge held the request for an unreasonable amount of time.

The fix

The fix depends on which phase dominated. TLS-dominant: session resumption, OCSP stapling, HTTP/2 on origin; or terminate TLS at the edge with a long-lived origin connection. Server-time-dominant on cache miss: PHP-FPM tuning, page cache work, or database indexing. DNS-dominant: faster authoritative DNS, lower TTLs only where needed. Edge-time-dominant: workers or rules holding the request, usually misconfigured.


Stack Harbor breaks down request lifecycles as part of an Enterprise WordPress engagement. If your TTFB number is bad and you do not know why, a 30-minute review is usually enough to find the dominant phase.