Measuring Time to First Byte with curl
Time to first byte (TTFB) is the delay between asking for a page and receiving the first byte of the answer. It is the most direct window into how quickly a server starts working, and you can measure it with a tool that is already installed on most computers.
Method note · Updated November 2026
The command
curl can print timing information after a request with its --write-out option (short form -w). A useful starting point:
curl -o /dev/null -s -w "dns %{time_namelookup}\nconnect %{time_connect}\ntls %{time_appconnect}\nfirstbyte %{time_starttransfer}\ntotal %{time_total}\n" https://example.com/
Each value is in seconds, counted from the start of the request. They are cumulative, so each one includes the steps before it.
| Variable | What it marks |
|---|---|
time_namelookup | DNS lookup finished |
time_connect | TCP connection established |
time_appconnect | TLS handshake finished (HTTPS only) |
time_starttransfer | First byte of the response received |
time_total | Whole transfer finished |
Splitting network time from server time
The raw first-byte number mixes distance with server work. Subtracting gives a cleaner picture. time_starttransfer minus time_appconnect is roughly the time the server spent producing the start of its answer, plus one network round trip. If that gap is large while connect time is small, the server or application is the slow part. If connect and TLS times are large, the distance or network is.
web.dev suggests that most sites aim for a TTFB of 0.8 seconds or less, measured as the experience of real users. Treat that as a rough guide for whole-page TTFB, not a pass mark for a lab test from one machine.
Making the number trustworthy
- Repeat it. Run the command many times in a simple loop and keep every result. Report the median and the slowest few, not the best.
- Test a real page. Use a page that does what your site does, such as a post with comments or a product page, not a static file.
- Note caching. Check the response headers with
curl -sIto see whether a cache answered. Test cached and uncached pages separately. - Note the location. Write down where the command ran. Results from a laptop on home Wi-Fi and from a server in a data center are not comparable.
- Keep versions. Record the date, plan, PHP or runtime version, and any caching plugin.
The first request often includes a cold start: an empty cache, a sleeping process or a DNS lookup that later requests skip. Keep it, but label it, because some visitors really do get that first slow answer.
TTFB is only one measure. Once you know the server starts quickly, the rest of the page load depends on file sizes and browser work, covered in the hosting guide. Domain topics such as WHOIS privacy or the registrar basics do not affect TTFB, apart from the DNS step shown above.
Sources and further reading
- curl project documentation — the
--write-outoption and its variables. - web.dev (Google) — "Optimize Time to First Byte".
- MDN Web Docs — PerformanceResourceTiming and the responseStart property.