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:
- Execute your application code
- Fetch any required data (database queries, API calls)
- Render HTML on the server
- 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.