Course contentsShow
← Web Development
Lesson 1730 of 2,98232. Server-Side Rendering ConceptsFree lesson

Time to First Byte (TTFB)

Understand TTFB as the time from request to first byte of response and why it matters for SSR.

Time to First Byte (TTFB)

You'll learn what TTFB measures and why it's a critical performance metric for server-side rendering.

What is TTFB?

Time to First Byte (TTFB) is the duration between a browser sending an HTTP request and receiving the very first byte of response data from the server. Think of it like ordering food at a restaurant: TTFB is the time from placing your order until the waiter brings out your first dish—not the time it takes to eat everything.

TTFB includes:

  • DNS lookup time
  • Connection establishment (TCP handshake, TLS negotiation)
  • Request travel time to the server
  • Server processing time
  • Response travel time back to the browser (first byte only)

Why TTFB Matters for SSR

With server-side rendering, TTFB becomes especially important because the server must:

  1. Execute your application code
  2. Fetch any required data (database queries, API calls)
  3. Render HTML on the server
  4. Send that HTML back

All of this happens before the first byte arrives at the browser. A slow TTFB means users stare at a blank screen longer, even though SSR is supposed to show content faster than CSR.

Compare this to static site generation (SSG), where the HTML is pre-built—the server just reads a file and sends it, resulting in much faster TTFB. Or CSR, where the server immediately sends a minimal HTML shell, giving a fast TTFB but delaying actual content.

Optimizing TTFB in SSR often means caching strategies, faster database queries, and efficient server processing.

Key Takeaway: TTFB measures the time until the browser receives the first response byte; in SSR, high TTFB directly delays visible content, making it a critical optimization target.