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 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.comThe 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.
Fix server processing time by profiling your backend — database query time is the most common culprit in dynamic apps.
