What is TTFB?
Time to First Byte (TTFB) measures the time from when a browser requests a page to when it receives the first byte of data. It includes DNS lookup, TCP connection, SSL negotiation, and server processing time.
Why TTFB Matters
A slow TTFB delays all other metrics. If your server takes too long to respond, LCP, FCP, and other metrics will suffer regardless of frontend optimization.
Steps to Improve TTFB
Use a CDN
Serve content from edge servers close to users. Popular CDNs include Cloudflare, Fastly, and AWS CloudFront.
Enable Server-Side Caching
Cache database queries, API responses, and rendered HTML. Use Redis or Memcached for in-memory caching.
Optimize Database Queries
Index frequently queried columns, avoid N+1 queries, and use query result caching.
Use HTTP/2 or HTTP/3
Modern protocols reduce connection overhead and enable multiplexing.