http-redirectweb-vitals

Does TTFB include the time for the request that redirects to my page?


I am calculating TTFB (Time to First Byte) and other web vitals on a page using the web-vitals javascript library.

The flow is like this:

  1. The user, looking at a web page from server A, is clicking a button or other link, resulting in a request that goes to server A.
  2. Server A analyses the request and returns a redirect, probably 303, with the link to my page, that is on server B.
  3. The browser is redirected to my page on server B, that is loaded with the content.

In my page on server B, I measure TTFB.

Will the TTFB I measure include the time it took to get the redirect from server A?


Solution

  • Yes, TTFB as measured by the Chrome UX Report (the dataset that powers Google's Web Vitals program) includes redirect times.

    The definition quoted on the Chrome UX Report docs linked above is:

    Time to first byte (TTFB) is a measurement used as an indication of the responsiveness of a webserver or other network resource. TTFB measures the duration from the user or client making an HTTP request to the first byte of the page being received by the client's browser. This time is made up of the socket connection time, the time taken to send the HTTP request, and the time taken to get the first byte of the page.

    From Wikipedia

    The reason why redirects are included in the metric is because that's what end-users experience as they wait for a page to load. Measuring only a subset of that time may paint an unrealistic picture of the UX.

    Navigation Timing Level 2 image showing TTFB from the navigation start time of prompt for unload to the response start time.

    Borrowing a graphic from the Navigation Timing spec, TTFB is represented by the stages in the red box above.