Script Valley
Web Performance Fundamentals
How Browsers Load PagesLesson 1.2

What is TTFB and how does server response time affect page speed

TTFB definition, DNS lookup, TCP handshake, TLS negotiation, server processing, waterfall chart

Time to First Byte (TTFB)

TTFB timeline diagram

TTFB measures the time from the browser sending an HTTP request to receiving the first byte of the response. It is the foundation everything else stacks on top of. A slow TTFB delays every subsequent resource.

TTFB has four components:

  • DNS lookup - resolving the domain to an IP (cached after first visit)
  • TCP handshake - establishing the connection (3 round trips)
  • TLS negotiation - for HTTPS, another 1–2 round trips
  • Server processing - the time your server takes to generate the response

Google's Core Web Vitals threshold is under 800ms. Below 200ms is excellent.

# Measure TTFB with curl
curl -o /dev/null -s -w \
  "DNS: %{time_namelookup}s
Connect: %{time_connect}s
TTFB: %{time_starttransfer}s
" \
  https://example.com

The biggest lever on TTFB you control immediately is server location. A server in London responding to a user in Mumbai adds ~150ms of pure physics before a single line of your code runs. A CDN with edge nodes solves this by serving responses from nodes geographically close to the user.

For server processing time specifically, profiling your backend usually reveals database queries as the dominant cost - even a single unindexed query can add hundreds of milliseconds to every TTFB.

Up next

What are render-blocking resources and how to eliminate them

Sign in to track progress