performancenetwork-programmingtime-to-first-byte

What makes up the TTFB (Time-To-First-Byte) calculation, and how to see individual component timings?


I'm seeing high Time-To-First-Byte numbers reported in chrome dev tools for network requests. I'd like to improve it, but I'm not sure which part of the request process is leading to slow speeds.

Some sources quote this measurement as "DNS, SSL, Connect, Send, Receive, Wait". What is the authoritative definition of TTFB, and how can you accurately measure the pieces of it?


Solution

  • Using Wireshark as analysis tool to get details of the request.

    Result: wireshark screenshot

    Analysis

    DNS : time at packet 6
    TCP handshake : Difference between packate 10 and 6
    TLSv1.2 handshake: Difference between packet 23 and 10
    Send : Difference between packet 23 and 24 (? not sure)
    TTFB : time at packet 27

    Wait time as regarded by browsers is the time a request has been waiting in the requests queue before it's served.

    References:

    http://www.thevisiblenetwork.com/2015/01/21/calculate-http-response-time-in-wireshark/ http://blog.catchpoint.com/2017/05/12/dissecting-tls-using-wireshark/