What Happens When You Press Enter in the Browser URL Bar: From URL Parsing to TCP Handshake and HTTP Response
This article explains step‑by‑step what occurs when a user types a URL and presses Enter, covering URL parsing, DNS resolution, TCP three‑way handshake and four‑way termination, HTTP request/response formation, and the browser’s rendering process, providing interview‑ready insights into web networking fundamentals.
URL Parsing
When a user enters an address such as https://segmentfault.com/a/1190000023475177 , the browser first parses the URL according to the pattern scheme://host.domain:port/path/filename . The components are:
scheme : application‑layer protocol (e.g., http, https, ftp).
host : the domain name (default for http is www ).
domain : the registered internet domain (e.g., segmentfault.com ).
port : service port (80 for http, 443 for https).
path : resource location on the server.
filename : the actual file or resource name.
DNS Query
The browser cannot reach a server by domain name alone; it must resolve the name to an IP address. The resolution proceeds through several caches and servers:
Browser cache.
Operating‑system cache.
Router cache.
ISP’s DNS server.
Root DNS servers (recursive lookup).
TCP Connection Establishment and Termination
After obtaining the IP, the client establishes a TCP connection. TCP uses a four‑layer model (Application, Transport, Network, Link) where each layer adds its own header.
Three‑Way Handshake
The handshake proceeds as follows:
Client sends a SYN packet (state SYN_SENT ).
Server replies with SYN‑ACK (state SYN_RCVD ).
Client sends ACK, moving both sides to ESTABLISHED .
This establishes a reliable, full‑duplex channel.
Four‑Way Handshake (Connection Teardown)
When the communication ends, the parties exchange FIN and ACK packets in four steps, ending with the client entering TIME_WAIT to ensure the final ACK is received and to allow any delayed duplicate segments to expire.
The TIME_WAIT state also prevents port reuse conflicts and helps clean up sockets that might otherwise linger in CLOSE_WAIT or SYN_RCVD due to bugs or attacks.
HTTP Request and Response
With the TCP link ready, the browser constructs an HTTP request. An HTTP message consists of:
Start line (e.g., GET / HTTP/1.1 ).
Header fields (key: value pairs, case‑insensitive, no spaces in keys).
Blank line (CRLF).
Optional body (entity).
Typical request methods include GET, POST, HEAD, PUT, DELETE, OPTIONS, TRACE, CONNECT . The server processes the request, builds a response with its own start line, headers, and optional body, and sends it back over the same TCP connection.
Browser Rendering
Upon receiving the HTTP response containing HTML, the browser renders the page through these steps:
Parse the HTML to build the DOM tree.
Parse CSS to create the CSS rule tree.
Combine DOM and CSS trees to generate the render tree.
Layout: compute geometry for each node.
Paint: draw pixels on the screen.
This pipeline explains why network latency, TCP handshakes, and HTTP headers directly affect the perceived loading speed of a web page.
IT Services Circle
Delivering cutting-edge internet insights and practical learning resources. We're a passionate and principled IT media platform.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.