Logo

Command Palette

Search for a command to run...

Blog
PreviousNext

What Happens When You Type a URL?

From browser cache to DNS, TCP/TLS handshakes, HTTP requests, and load balancers - a step-by-step breakdown of what happens when you hit Enter.

Ever wondered what happens when you hit "Enter" after typing a URL and seeing a webpage appear? Let's break it down!

1. The Instant Check: Your Browser's Cache

Before your request even thinks about leaving your computer, your browser performs a quick check. It asks its own cache. If the answer is yes, and the resource hasn't expired, your browser is smart enough to just use the cached version. This is why frequently visited websites often load super fast!

2. The Phonebook Lookup: DNS Resolution

If the resource isn't cached, or it's a new request, the first real step is translating the human-readable domain name (like www.google.com) into a machine-readable IP address (like 142.250.193.46). This is called DNS (Domain Name System) lookup (you can also look up yourself, just write ping google.com in bash/zsh), and it's like asking a giant internet phonebook for the correct number.

3. Making Friends: The TCP 3-Way Handshake

Once your browser has the IP address, it needs to establish a reliable connection with the server. It does this using the Transmission Control Protocol (TCP) and a process called the "3-way handshake." Think of it as a polite greeting:

  • SYN: Your browser sends a "SYN" (synchronize) message to the server, saying "Hello, I want to talk."
  • SYN-ACK: The server responds with "SYN-ACK" (synchronize-acknowledge), essentially saying "Hello back, I'm ready, and I acknowledge your request."
  • ACK: Your browser sends an "ACK" (acknowledge) back, confirming "Great, let's chat!"

4. The Secret Code: TLS Handshake (for HTTPS)

If the URL starts with https:// (which most do these days), an extra layer of security kicks in: the TLS (Transport Layer Security) handshake. This ensures that all communication between your browser and the server is encrypted and secure. It's like agreeing on a secret code before you start sharing sensitive information. This step involves exchanging certificates and cryptographic keys.

5. Asking for the Goods: HTTP Request Sent

With a secure connection established, your browser finally sends the actual request for the webpage. This is an HTTP (Hypertext Transfer Protocol) request, typically a GET request, asking for a specific resource, like GET /index.html. It also sends along other information, such as your browser type and any cookies.

6. The Traffic Cop: Load Balancer Routes Traffic

For large websites, your request doesn't go directly to a single server. Instead, it hits a load balancer. This smart device acts like a traffic cop, distributing incoming requests across multiple backend servers. This prevents any single server from getting overloaded, ensuring the website remains fast and responsive.