# TTFB

> TTFB (Time To First Byte): web performance metric measuring the delay between an HTTP request and the first byte of the response — the main gauge of server latency.

- **Category**: Technical
- **URL**: https://www.romaindelfosse.fr/en/glossary/ttfb/

---

**TTFB** (Time To First Byte) is a web performance metric that measures the delay between the moment a browser sends an HTTP request and the moment it receives the first byte of the server's response. It's the most direct indicator of the latency a user perceives: before the page can start rendering, the browser has to receive the beginning of the response. A high TTFB makes a site feel slow even if the rest of the load is fast — which makes it one of the first things to optimize in a web application.

## Technical definition

### The four components of TTFB

When a user types `https://example.com/` into the browser and hits Enter, several steps happen before the first byte comes back:

1. **DNS resolution** — translating the domain name into an IP address. Typical cost: 10 to 100 ms, which the local DNS cache can absorb.
2. **TCP connection** — establishing the connection with the server. Typical cost: one network round trip (RTT), i.e. 10 to 200 ms depending on geographic distance.
3. **TLS handshake** — negotiating HTTPS encryption. Typical cost: 1 to 2 additional RTTs, down to 0 RTT with TLS 1.3 and session resumption.
4. **Server processing time** — running the application code, database queries, rendering the response. This step largely dominates TTFB on a dynamic application like WordPress, and it's the one where you have the most room to maneuver.

### TTFB and Core Web Vitals

Since 2021, Google has included the **Core Web Vitals** in its SEO ranking criteria. Today they are LCP, INP and CLS: INP [replaced FID in March 2024](https://web.dev/blog/inp-cwv-march-12?utm_source=romaindelfosse&utm_medium=glossaire&utm_campaign=ttfb). TTFB, although it isn't a Web Vital in its own right, is a health indicator that directly affects **Largest Contentful Paint (LCP)**: if the server takes 2 seconds to start responding, LCP can't be better than 2 seconds. Improving TTFB is therefore a necessary (but not sufficient) condition for a good Core Web Vitals score.

## Current challenges

### TTFB as a window into the infrastructure

TTFB is an excellent diagnostic of infrastructure health. A TTFB that varies widely from one request to the next points to contention (an undersized database, cache misses, saturated PHP workers). A TTFB that's consistently high across all requests points to a structural problem: undersized hosting, a poorly optimized application, or excessive network latency. The first thing I do when asked to audit the performance of a WordPress site is look at TTFB across several URLs — it immediately gives a sense of how much effort will be needed.

### The impact of security plugins on TTFB

On a typical WordPress install, each security plugin adds a measurable cost to TTFB: it inserts itself into the loading path, checks every request, writes logs and queries its configuration in the database. Stacking several security plugins can push TTFB from a few hundred milliseconds to more than a second, with no functional gain for the user. Moving these controls to the infrastructure level (Nginx, HTTP headers, immutable filesystem) removes that cost while improving security posture — the double benefit I'm testing in [my article on securing WordPress with Infrastructure as Code](/en/blog/securiser-wordpress-sans-plugins-infrastructure-as-code/).

## Practical applications

### Measuring TTFB

The most widely used tools for measuring TTFB are: the Network tab of the browser DevTools ("Waiting (TTFB)" column), [WebPageTest](https://www.webpagetest.org/), [PageSpeed Insights](https://pagespeed.web.dev/), and the CrUX report (Chrome User Experience Report), which aggregates real measurements from Chrome users worldwide. For continuous monitoring, an APM tool (Datadog, New Relic, Sentry Performance) lets you track TTFB over time and spot regressions.

### Optimizing without breaking things

Improving TTFB can introduce bugs if you don't measure. Turning on an aggressive HTTP cache for a page that should be dynamic turns a "slow but correct" page into a "fast but wrong" one. The golden rule: every optimization should come with functional tests that confirm the behavior is still correct — ideally automated in CI.



## Frequently Asked Questions

### What exactly does TTFB measure?

TTFB adds up four distinct durations: (1) DNS resolution of the domain name, (2) establishing the TCP connection with the server, (3) TLS negotiation (the SSL/TLS handshake over HTTPS), (4) server processing time (running the application code, database queries, generating the response). In practice, on a PHP application like WordPress, the 4th component far outweighs the first three: most TTFB improvements come from server-side and application optimization.

### What is a good TTFB value?

According to web.dev (Google), a TTFB of 0.8 seconds or less is good, anything above 1.8 seconds is poor, and anything in between needs improvement. TTFB isn't one of the Core Web Vitals, but it directly affects LCP, which is, and therefore indirectly SEO rankings. For a site served by a good CDN with HTTP caching, TTFB can drop below 50 ms. For an unoptimized WordPress site, it commonly exceeds 1 second, which badly hurts how fast the site feels.

### What are the levers for improving a web application&#39;s TTFB?

The most effective ones, in order of impact: (1) enable an HTTP cache at the reverse proxy or CDN level so that frequently requested pages are served without running the application code, (2) enable OPcache with validate_timestamps=0 to eliminate PHP recompilation, (3) set up an object cache (Redis, Memcached) to avoid repeated database queries, (4) optimize the slow SQL queries identified with a profiler, (5) use a CDN with points of presence close to your users, (6) move to HTTP/2 or HTTP/3 to reduce connection latency, (7) cut down the number of plugins that run on every request in WordPress.



## Resources

- [Time to First Byte (TTFB) — web.dev](https://web.dev/articles/ttfb?utm_source=romaindelfosse&amp;utm_medium=glossaire&amp;utm_campaign=ttfb) — Google Chrome DevRel

- [Core Web Vitals — Google Search Central](https://developers.google.com/search/docs/appearance/core-web-vitals?utm_source=romaindelfosse&amp;utm_medium=glossaire&amp;utm_campaign=ttfb) — Google

