Menu
The request/response cycle
“Everything that happens between pressing Enter and seeing the page.”
You type https://example.com and press Enter. Here’s what happens, in order.
1. DNS: find the server’s address#
Computers connect to IP addresses, not names. The browser asks a DNS resolver: *“what’s the IP of example.com?"*The answer is cached for a while (the record’s TTL), so the next visit usually skips this step.
dig +short example.com93.184.215.142. Open a connection#
The browser opens a TCP connection to that IP on port 443 (because the scheme is https). HTTP/3 uses QUIC over UDP instead, but the role is the same: a reliable channel between the two machines.
3. TLS handshake#
For https, client and server use TLS to agree on encryption keys and the server proves it really is example.com with a certificate. After this, everything is encrypted.
Tip
curl -v shows this step too. Look for lines like SSL connection using TLSv1.3 and server certificate verification OK.
4. Send the request#
Now the actual HTTP request goes over the connection:
1GET / HTTP/1.1
2Host: example.com
3User-Agent: Mozilla/5.0 ...
4Accept: text/html5. Get the response#
The server finds (or generates) the page and answers:
1HTTP/1.1 200 OK
2Content-Type: text/html; charset=utf-8
3
4<!doctype html>
5<html>...6. …and then many more requests#
The HTML mentions CSS, JavaScript and images. For each of those the browser sends another request, usually reusing the same connection. A typical page makes dozens of them. Open your browser’s DevTools → Network tab and reload any page to see the list.
Measure it#
curl can time each phase:
curl -o /dev/null -s -w "dns: %{time_namelookup}s\nconnect: %{time_connect}s\ntls: %{time_appconnect}s\nfirst byte: %{time_starttransfer}s\ntotal: %{time_total}s\n" https://example.comdns: 0.012s
connect: 0.031s
tls: 0.068s
first byte: 0.101s
total: 0.102sNotice how much time passes before the first byte of the response arrives. That’s why reusing connections matters.
Answer these 3 questions to commit this byte to your learning path.
Reset. This byte isn't committed any more. Answer the questions again to commit it.
$ git commit -m "learn(http): The request/response cycle"
[main 0ea5d11] learn(http): The request/response cycle
1 byte changed, 3 insertions(+)
See it on your path Already committed . Try the questions again any time, it won't undo anything. To uncommit it and start over: