Skip to main content
sitewarm
Performance & SEO

What is TTFB (time to first byte)?

TTFB is the time from starting navigation to the first byte of the response. A cache miss adds the origin round trip to it. About 0.8 s or less is good.

TTFB, or time to first byte, measures the time from when a browser starts a navigation to when the first byte of the response arrives. It includes redirects, DNS, the connection and TLS, and the server's response time. On a CDN cache miss, that last part includes the trip to the origin and generating the page.

new PerformanceObserver((list) => {
  const [nav] = list.getEntriesByType("navigation");
  console.log("TTFB", nav.responseStart);
}).observe({ type: "navigation", buffered: true });

web.dev suggests that most sites should aim for a TTFB of 0.8 seconds or less, and rates above 1.8 seconds as poor. TTFB is not a Core Web Vital itself, but it comes before every rendering metric: the browser cannot paint anything until the HTML arrives.

  • A high TTFB delays FCP and LCP by the same amount.
  • Google's crawlers use response times, including TTFB, to decide how fast they can crawl. See crawl budget.
  • Serving HTML from a warm cache removes the origin time from TTFB, which is the main effect of cache warming on speed.

References

  1. web.dev: Time to First Byte (TTFB)https://web.dev/articles/ttfb
  2. web.dev: Optimize Largest Contentful Painthttps://web.dev/articles/optimize-lcp

Warm your cache after every deploy

sitewarm requests the pages in your sitemap after a deploy and reports the cache state the CDN returns for each one, with the vantage point it was measured from.