Time to First Byte (TTFB)
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 includesDNS lookup and establishing the connection using aTCP handshake andTLS handshake if the request is made overHTTPS.
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 theresponseStart attribute ofPerformanceNavigationTiming:
js
const ttfb = performance.getEntriesByType("navigation")[0].responseStart;Note:For sites using103 Early Hints, TTFB is typically thefirst bytes (after any redirects) — and so, the 103 interim response. Site owners wishing to measure the time until the final response should usefinalResponseHeadersStart, where supported.