Time to first byte
Time to First Byte (TTFB) refers to the time between the browser requesting a page and when it receives the first byte of information from the server. This time includes DNS lookup and establishing the connection using a TCP handshake and TLS handshake if the request is made over HTTPS.
TTFB is the time it takes between the start of the request and the start of the response, in milliseconds. This can be measured using the
attribute of requestStart
PerformanceNavigationTiming
:
javascript
const ttfb = performance.getEntriesByType("navigation")[0].responseStart;
Note:
For sites using 103 Early Hints
, TTFB is typically the first bytes (after any redirects) — and so, the 103 interim response. Site owners wishing to measure the time until the final response should use
, where supported.finalResponseHeadersStart