# Introduction Measures [time-to-first-byte](https://en.wikipedia.org/wiki/Time_to_first_byte) for single or multiple URLs. Can show you quickest, slowest & median TTFB values plus optionally log all response headers. [![Build Status](https://app.travis-ci.com/jaygooby/ttfb.sh.svg?branch=master)](https://app.travis-ci.com/jaygooby/ttfb.sh) ![Sample run of ttfb.sh](https://github.com/jaygooby/ttfb.sh/raw/readme-assets/demo.gif) ``` Usage: ttfb [options] url [url...] -d debug -l (infers -d) log response headers. Defaults to ./curl.log -n of times to test time to first byte -v verbose output. Show response breakdown (DNS lookup, TLS handshake etc) ``` Implicitly follows a redirection chain using curl's `-L` option. Can log all response headers (the default log file is `./curl.log`) by calling with `-d`. Override the default log file by specifying `-l /some/file`. Get quickest, slowest and median TTFB values by specifying the number of times to call a URL; use `-n2` for 2 tests, `-n5` for 5 and so on. Uses the calculation `%{time_starttransfer¹} - %{time_appconnect²}` which doesn't include any connection overhead, to better approximate [devtool’s TTFB figure](https://developers.google.com/web/tools/chrome-devtools/network/understanding-resource-timing#slow_time_to_first_byte). ¹ [`time_starttransfer`](https://github.com/curl/curl/blob/e431daf013ea04cb1a988a2009d820224ef5fb79/docs/cmdline-opts/write-out.d#L141-L144) > The time, in seconds, it took from the start until the first byte was just about to be transferred. This includes time_pretransfer and also the time the server needed to calculate the result. ² [`time_appconnect`](https://github.com/curl/curl/blob/e431daf013ea04cb1a988a2009d820224ef5fb79/docs/cmdline-opts/write-out.d#L118-L120) >The time, in seconds, it took from the start until the SSL/SSH/etc connect/handshake to the remote host was completed. # Genesis Based on a [gist](https://gist.github.com/sandeepraju/1f5fbdbdd89551ba7925abe2645f92b5) by https://github.com/sandeepraju Modified by jay@gooby.org, [@jaygooby](https://twitter.com/jaygooby) # Usage ``` Usage: ttfb [options] url [url...] -d debug -l (infers -d) log response headers. Defaults to ./curl.log -n of times to test time to first byte -o