Overview
When diagnosing a slow website, browser Developer Tools display waterfalls showing connection phases, but browser extensions, local caching, and UI rendering can obscure raw server performance.
The command-line tool curl provides a powerful -w (write-out) option that isolates each phase of an HTTP/HTTPS network transaction: DNS resolution, TCP handshake, TLS cryptographic negotiation, server processing time (Time to First Byte / TTFB), and total transfer duration.
In this tutorial, you will learn how to structure curl timing commands for Windows and Unix environments, interpret each timing metric, and avoid common performance misinterpretations.
Anatomy of an HTTP Request in curl
When your computer requests a webpage via HTTPS, the network interaction progresses through distinct sequential stages:
|-- DNS Lookup --|
|------ TCP Connection ------|
|---------- TLS Handshake ----------|
|----------------- Time to First Byte (TTFB) -----------------|
|----------------------- Total Request Time -----------------------|
The curl timing variables measure these milestones:
time_namelookup: Elapsed time from request start until DNS name resolution completes.time_connect: Elapsed time until the TCP connection (3-way handshake) to the remote host is established.time_appconnect: Elapsed time until the TLS/SSL cryptographic handshake completes.time_starttransfer(TTFB): Elapsed time until the server transmits the first byte of the HTTP response header. This reflects backend processing (PHP execution, database queries).time_total: Total time for the complete transaction until the final byte is received.
Testing Commands by Operating System
To prevent terminal clutter, we discard the response body (-o /dev/null on Linux/macOS or -o NUL on Windows) and run curl silently (-s).
Windows (PowerShell & Command Prompt)
On Windows PowerShell, curl can be aliased to Invoke-WebRequest. Always use curl.exe to invoke the actual curl executable:
curl.exe -s -o NUL -w "namelookup: %{time_namelookup}s`nconnect: %{time_connect}s`nappconnect: %{time_appconnect}s`nstarttransfer: %{time_starttransfer}s`ntotal: %{time_total}s`n" https://example.com
Linux & macOS (Bash / Zsh)
On Unix-like terminals, route output to /dev/null:
curl -s -o /dev/null -w "namelookup: %{time_namelookup}s\nconnect: %{time_connect}s\nappconnect: %{time_appconnect}s\nstarttransfer: %{time_starttransfer}s\ntotal: %{time_total}s\n" https://example.com/
Example Output:
namelookup: 0.031823s
connect: 0.050001s
appconnect: 0.274472s
starttransfer: 0.283956s
total: 0.284057s
How to Interpret Your Results
Analyzing which specific phase takes the longest identifies the source of latency:
1. High time_namelookup (> 0.2s)
- Diagnosis: DNS resolution is slow.
- Resolution: Inspect your authoritative DNS provider, consider switching to high-performance Anycast DNS, or lower TTL if testing recently modified records.
2. High time_connect minus time_namelookup (> 0.15s)
- Diagnosis: High network latency or geographic distance between your client machine and the hosting server.
- Resolution: Ensure your hosting server is located close to your target audience (e.g. Mumbai, India for domestic users), or implement a CDN edge proxy.
3. High time_appconnect minus time_connect (> 0.2s)
- Diagnosis: Slow TLS handshake.
- Resolution: Ensure your server supports TLS 1.3, which reduces the cryptographic handshake from two round trips to one.
4. High time_starttransfer minus time_appconnect (> 0.8s)
- Diagnosis: Backend server processing delay. This is the classic TTFB bottleneck.
- Resolution: This indicates server-side execution lag. Common culprits include unoptimized WordPress plugins, missing database indexes, absence of object caching (Redis), or insufficient server compute resources. Review our guide on vCPU sizing and RAM in web hosting.
Safety and Measurement Guardrails
- Never Include Secrets: When testing authenticated endpoints or private APIs, never paste production bearer tokens, private cookies, or administrative session headers into shared scripts or public documentation.
- Contextual Evaluation: A single curl test is not a full website performance audit. Real user experience is governed by Core Web Vitals (Largest Contentful Paint, Cumulative Layout Shift), which require full browser rendering audits.
Frequently Asked Questions
Does a fast TTFB in curl mean my entire webpage will load fast in a browser?
No. curl tests a single raw HTTP request. It does not parse HTML, download external CSS/JavaScript assets, execute client-side scripts, or render images. Complete browser speed also depends on frontend asset size and client rendering efficiency.
Why does curl say 'command not found' or run Invoke-WebRequest in PowerShell?
In Windows PowerShell, 'curl' is historically aliased to Invoke-WebRequest. To run the real curl utility on Windows, always type 'curl.exe' rather than 'curl'.
How many times should I run a curl timing test?
Run the test 3 to 5 times and evaluate the median. A single test may encounter temporary routing jitter or cold caches that do not reflect sustained server performance.
Need Technical Assistance?
Web Hosting Wale support is available 24/7. Tickets are typically answered within 10-15 minutes.