# Time to first byte (TTFB)

What is time to first byte (TTFB)?

Time to first byte (TTFB) is how long a browser waits, from the moment it starts loading a page, until the first byte of the server's response arrives. Nothing can appear on screen until that first byte is in.

## How it works

As web.dev defines it, TTFB is the sum of these request phases:

- redirect time
- service worker startup time, if the page uses one
- the [DNS](/glossary/dns) lookup
- the connection and [TLS](/glossary/tls) negotiation
- the request itself, up to the moment the first byte of the response arrives

The last phase is where the server does its work: running application code, querying the database and starting to send the page. A slow TTFB can come from the network (a distant server, a chain of redirects) or from the backend.

web.dev gives a rough guide of 0.8 seconds or less as good, and more than 1.8 seconds as poor. TTFB is not a Core Web Vitals metric, so by web.dev's account a site does not have to meet that threshold, as long as the wait does not keep it from scoring well on the metrics that are. It still comes before every other loading metric, so a slow first byte delays First Contentful Paint and Largest Contentful Paint.

## Why it matters

Every millisecond of TTFB is a millisecond the visitor looks at a blank page. A rising TTFB is also often the first sign of trouble on the backend, such as a slow query, a server short of workers, or a cache that stopped answering.

## What can go wrong

- A cache in front of the site is emptied or bypassed, after a deploy for example, and every request reaches the application.
- A new query, or a loop that runs one query per row, makes one page much slower than the rest.
- Redirects, such as `http://` to `https://` and then to `www`, each add a full request before the real page is even asked for.
- The server is far from the visitor, so connection setup alone takes a large share of the time.

## Check it

The [HTTP status & speed check](/tools/http-status) requests a URL once and splits the response time into DNS lookup, TCP connect, TLS handshake and server processing. Its server processing phase on its own is only the wait for the first byte; a browser's TTFB also includes the DNS, connection and TLS phases the tool shows separately, plus any redirects. Ranetrace's [performance monitoring](/features/performance-monitoring) keeps the response time history, so you can see when a site got slower.

Read this definition in a browser: https://ranetrace.com/glossary/ttfb
