How to Measure and Reduce Time to First Byte Across Hosting, DNS, and CDN Layers
TTFBwebsite speedbenchmarkingCore Web Vitalsperformance diagnostics

How to Measure and Reduce Time to First Byte Across Hosting, DNS, and CDN Layers

CCaching.website Editorial Team
2026-12-04
7 min read

Learn how to measure TTFB across DNS, CDN, hosting, and application layers, then build a repeatable workflow to find and fix slow responses.

Time to first byte (TTFB) is useful only when you can explain what it includes. This workflow shows how to measure TTFB across DNS, network, CDN, web-server, application, and database layers, then compare repeatable results to find the slow component. Use it after migrations, releases, CDN changes, traffic increases, and as part of a monthly or quarterly performance review.

Overview

TTFB is the elapsed time between starting a request and receiving the first byte of the response. It is an early signal of responsiveness, but it is not a single server metric. A browser or testing tool may spend time resolving DNS, opening a TCP connection, negotiating TLS, waiting for a CDN edge, forwarding a request to the origin, executing application code, querying a database, and transferring the response across the network.

That distinction matters when troubleshooting. A slow result from one region does not necessarily mean the hosting server is overloaded. A high TTFB for anonymous visitors may indicate a cache miss or poor edge coverage, while a high TTFB for logged-in users may be caused by application or database work that cannot be publicly cached. The goal is to separate these paths before changing configuration.

Measure at more than one layer:

  • Real-user monitoring: shows what visitors experience across devices, networks, regions, and page types.
  • Browser-based testing: shows the relationship between TTFB, rendering, and other Core Web Vitals.
  • Command-line tests: provide repeatable timing fields and response headers for controlled comparisons.
  • Server and CDN logs: explain whether time was spent at the edge, in the origin server, in application code, or in the database.

Do not treat one test as a verdict. Establish a baseline using the same URL, request state, test regions, protocol, and cache conditions. Record the test date and deployment version so that a later result can be compared with the correct context.

What to track

Build an evidence table

A simple evidence table prevents teams from collapsing every delay into “the host is slow.” Capture at least the following fields for each request:

LayerUseful fieldsWhat a change may indicate
DNSResolver, DNS lookup time, record type, answer locationResolver delay, delegation problems, or an unexpected DNS path
ConnectionTCP connect time, TLS negotiation time, protocolNetwork distance, connection setup overhead, or transport changes
CDN and edgeEdge region, cache status, cache key, Age or provider cache headersCache hit or miss, bypass rule, cold edge, or routing issue
OriginOrigin-connect time, upstream response time, server statusWeb-server queueing, PHP or application work, or an overloaded origin
ApplicationRoute, request type, logged-in state, application timingSlow code path, personalization, API dependency, or uncached content
DatabaseQuery duration, query count, connection time, slow-query entriesMissing indexes, expensive queries, lock contention, or connection pressure
ResponseTotal time, TTFB, status, size, cache-control headersCombined effect of the request path and response policy

Test at least one publicly cacheable page, one deliberately dynamic or personalized route, and—where relevant—an ecommerce page such as a cart or account page. For WordPress, include a page-cache candidate and a logged-in request. For a custom application, name the route and record whether it reads from a database or an external service.

Use repeatable command-line measurements

With curl, request timing fields can reveal where the wait occurs. This example follows redirects and prints DNS, connection, TLS, first-byte, and total timings:

curl -L -s -o /dev/null -w 'dns=%{time_namelookup}\nconnect=%{time_connect}\ntls=%{time_appconnect}\npretransfer=%{time_pretransfer}\nredirect=%{time_redirect}\nttfb=%{time_starttransfer}\ntotal=%{time_total}\nhttp=%{http_code}\nurl=%{url_effective}\n' https://example.com/

Run the same command several times, rather than relying on the fastest result. Compare a warm request with a cold or known-miss request when your CDN or server caching setup allows that distinction. Use response headers to confirm what happened:

curl -sSI https://example.com/

Look for cache-status headers supplied by your CDN or reverse proxy, along with Cache-Control, Age, ETag, and Vary. Header names differ by provider, so document the meaning of the headers used in your own environment. A cache hit should not automatically be assumed from a low TTFB, and a miss should not automatically be considered a fault; dynamic or private responses may be intentionally bypassing the cache.

Repeat tests from representative regions. Keep the origin region, CDN configuration, URL, request headers, and authentication state consistent. A region close to the origin can hide distance-related delays that visitors elsewhere experience.

Cadence and checkpoints

Make performance measurement a controlled routine rather than an emergency-only exercise. A monthly or quarterly review is usually sufficient for a stable site, with additional checks after meaningful changes.

  • Before a hosting migration: record regional TTFB, cache-hit behavior, origin timing, error rates, and the state of important dynamic routes.
  • After DNS or CDN changes: verify authoritative answers, edge routing, cache status, TLS timing, and origin traffic. Use a documented CDN migration checklist to compare before and after results.
  • After an application or WordPress release: test representative templates, logged-in behavior, cache invalidation, and database timing. A cache plugin can make public pages fast while leaving an expensive origin path unresolved.
  • During recurring reviews: compare the same URLs from the same regions and preserve the prior results. Track median and high-percentile values where your monitoring system provides them, rather than focusing only on an occasional maximum.
  • During traffic increases: correlate TTFB with CPU, memory, worker utilization, database connections, queue depth, cache-hit ratio, and origin requests. A timing increase that appears only under load needs capacity and concurrency investigation, not just a new TTL.

Keep a compact benchmark record with the date, deployment identifier, URL, region, device or network type, authentication state, cache status, DNS provider, CDN configuration, origin location, and relevant server metrics. This turns a speed test into an operational baseline.

How to interpret changes

Start with the largest changed component. If DNS time rises while connection and origin timings remain stable, investigate DNS delegation, resolver behavior, or record responses before changing application code. If TCP or TLS time rises only in distant regions, examine network distance, edge selection, protocol negotiation, and CDN routing.

If TTFB is high on cache misses but low on cache hits, inspect the origin request. Review web-server worker availability, PHP-FPM or application queues, upstream services, and database queries. For Nginx FastCGI Cache, Varnish, or a managed WordPress cache, confirm that the request is reaching the intended cache layer and that cookies, authorization headers, query strings, and Vary rules are not creating unnecessary bypasses. A cache audit can help distinguish a real miss from a response that is correctly private.

If both hits and misses are slow, the bottleneck may be before the cache, at the edge, or in the network path. Check whether the test is measuring redirects, whether the hostname resolves to the expected service, and whether a security or routing layer is adding work. If only logged-in or personalized requests are slow, avoid making them publicly cacheable as a quick fix. Review application profiling, database timing, session storage, and personalization logic instead.

Use TTFB alongside page-level outcomes. A faster first byte does not guarantee a faster rendered page if the response blocks critical resources, sends excessive JavaScript, or delays meaningful content. Conversely, a geographically distant user may have a higher network component while still receiving a well-cached page quickly after the first byte. Review TTFB with Core Web Vitals, real-user data, page weight, and error rates.

For detailed cache investigation, compare this workflow with the website cache audit checklist and the guide to Cache-Control headers, TTLs, and revalidation. These checks are especially useful when a cache appears enabled but response behavior is inconsistent.

When to revisit

Revisit this process on a monthly or quarterly cadence, and immediately after a hosting migration, DNS change, CDN rule update, cache-plugin change, application release, database migration, traffic surge, or recurring user complaint. Also revisit it when monitoring shows a sustained shift rather than a single isolated outlier.

At each checkpoint, repeat the baseline requests, compare cache-hit and cache-miss paths, and check at least one logged-in or dynamic route. If a result changes, preserve the raw command output and correlate it with CDN logs, web-server access logs, application traces, and database metrics. Change one relevant variable at a time where possible, then rerun the same regional tests.

Finish each review with three decisions: what changed, which layer most likely caused it, and what measurement will confirm the next action. This keeps TTFB troubleshooting evidence-based and makes future hosting, caching, and DNS decisions easier to evaluate.

Related Topics

#TTFB#website speed#benchmarking#Core Web Vitals#performance diagnostics
C

Caching.website Editorial Team

Technical SEO Editors

Senior editor and content strategist. Writing about technology, design, and the future of digital media. Follow along for deep dives into the industry's moving parts.