What happens when you type 'google.com' into your browser?
It’s the classic interview question, but it’s also one of the most interesting ways to understand how the internet actually works.
When you type google.com and hit Enter, your browser goes on a massive scavenger hunt across the globe, all in a few hundred milliseconds.
The Big Picture: The Request Journey¶
sequenceDiagram
participant Browser
participant DNS
participant Server
Browser->>DNS: Hey, what's the IP for google.com?
DNS-->>Browser: It's 142.250.190.46
Browser->>Server: [TCP Handshake] Let's talk?
Server-->>Browser: [TCP Handshake] Sure!
Browser->>Server: [TLS Handshake] Let's talk securely?
Server-->>Browser: [TLS Handshake] Here's my certificate.
Browser->>Server: GET / HTTP/1.1
Server-->>Browser: 200 OK (HTML/CSS/JS) 1. The Scavenger Hunt (DNS)¶
Your browser doesn't know where google.com is. It only knows IP addresses (like 142.250.190.46). It asks a DNS Server (the phonebook of the internet) for the address.
2. The Secret Handshake (TCP/TLS)¶
Once it has the address, it reaches out to the server. They perform a TCP Handshake to make sure they can both hear each other, and then a TLS Handshake to encrypt the connection so nobody can snoop on your data.
3. The Order (HTTP)¶
Now that the "pipe" is open and secure, your browser sends an HTTP Request. It basically says: "Hey, can I have your homepage, please?"
4. The Delivery¶
The server looks at its files, finds the HTML, and sends it back as an HTTP Response. Your browser then reads that HTML and starts asking for images, CSS, and scripts to make it look pretty.
Wait, but why?¶
Why do we need all these steps? - DNS exists because humans are bad at remembering numbers like 142.250.190.46. - TLS exists because the internet is a public place, and without it, anyone between you and the server could read your passwords.
Common gotchas¶
- I always forget that your browser caches everything. If you've visited the site recently, it might skip the DNS step entirely because it already knows the address!
- Watch out for "Redirects": You might type
google.com, but the server tells you to go tohttps://www.google.cominstead. That's another round trip!
Try it yourself¶
You can see the raw HTTP request and response in your terminal:
Look for lines starting with> (what you sent) and < (what the server sent back). Further reading¶
- How DNS Works – A great comic-book style guide.
- Latency vs Throughput – Why each of these steps feels slow if your latency is high.
— Nadeem 🌐