# TTFB

> The TTFB (Time to First Byte) metric measures the time between the request and the first byte of the response.

## What is Time to First Byte (TTFB) and how do I reduce it?

The metric that measures how long it takes for the browser to receive the first byte of the response, including redirects, DNS, connection and server processing time. Affects all other loading metrics.

- Topic: Performance
- Type: concept

## Example

Wrong:

```http
Cache-Control: no-store
```

Right:

```http
Cache-Control: public, s-maxage=300, stale-while-revalidate=600
```

Letting the CDN cache a public page answers most requests at the edge instead of rendering it on every hit.

## Common mistakes

- Blaming the frontend for slow loads while the server spends seconds on database queries.

## Key points

- Cacheable pages are served from a CDN or cache, not rendered on every request.
- Server code does not wait on slow queries before sending anything, or it streams the response.
- Redirect chains are removed, since each redirect adds a full round trip.

## Interview questions

### What is a good TTFB?

About 0.8 seconds or less is considered good. It is a diagnostic metric, not one of the Core Web Vitals.

### Does TTFB include DNS and TLS time?

Yes. It covers redirects, DNS lookup, connection and TLS setup, and the server's processing until the first byte arrives.

### Why is TTFB high only on the first request?

Cold starts of serverless functions, empty caches and new connections add time that later requests skip.

## Related cards

- [Core Web Vitals](https://wonderium.dev/web/core-web-vitals.md)
- [CDN](https://wonderium.dev/web/cdn.md)
- [FCP](https://wonderium.dev/web/fcp.md)
- [LCP](https://wonderium.dev/web/lcp.md)
- [Streaming SSR](https://wonderium.dev/web/streaming-ssr.md)

---

- Level: [Web Platform](https://wonderium.dev/web.md)
- HTML version: https://wonderium.dev/web/ttfb
- Last updated: 2026-11-25
