From a URL to a response
Before the request
Follow DNS lookup and connection setup to see what must happen before a browser can send its first HTTP message.
7 minute lesson
Typing a URL does not send an HTTP request immediately.
First, the browser needs an IP address. DNS translates a hostname such as example.com into an address the network can reach.
Next, the browser opens a connection. Traditional HTTP/1.1 and HTTP/2 use TCP. HTTPS also performs a TLS handshake so the connection is encrypted and the server can prove its identity.
Only then can the browser send the HTTP request.
The exact sequence can be faster than it sounds. Browsers cache DNS results, reuse existing connections, and negotiate modern protocols. Still, keeping these layers separate helps when debugging:
- DNS answers where the host is.
- the transport connection carries bytes.
- TLS protects those bytes.
- HTTP defines the messages exchanged.
Lesson completed