EasyNetwork Optimization📖 Theory Question

What is TTFB (Time to First Byte) and what factors affect it?

💡

Hint

Time between the browser sending a request and receiving the first byte of the response — affected by DNS, TCP, TLS, server processing, CDN

Full Answer

TTFB measures the time from when the browser sends an HTTP request to when it receives the first byte of the response. Google's Core Web Vitals recommend TTFB under 800ms.

What TTFB includes:

  1. DNS resolution time.
  2. TCP connection time (3-way handshake).
  3. TLS negotiation time (if HTTPS).
  4. Server processing time (DB queries, SSR render, API calls).
  5. Time for the first byte to travel from server to client (network latency).

Improvement strategies:

  • CDN — serve responses from edge nodes close to the user; eliminates most of the geographic latency.
  • Edge computing — run SSR at edge (Vercel Edge Functions, Cloudflare Workers) to reduce round-trip to origin.
  • Server-side caching — cache rendered HTML or API responses in Redis; skip DB queries on cache hit.
  • HTTP/2 or HTTP/3 — fewer round trips, better connection reuse.
  • Optimize slow queries — profile DB and N+1 query problems; they directly inflate server processing time.
  • Persistent connectionsConnection: keep-alive avoids TCP handshake on repeated requests.

More Network Optimization Questions

EasyWhat is the difference between preload, prefetch, and preconnect?EasyHow does HTTP/2 multiplexing improve performance over HTTP/1.1?EasyWhat is the difference between defer and async on script tags?EasyWhat is image optimization and what techniques does Next.js Image component apply?

Practice this in a timed sprint →

5 free questions, no signup required

⚡ Start Sprint