A deep dive into what happens behind the scenes when you enter a URL in your browser—from DNS resolution to TCP connections and page rendering.


Exploring the three major memory management approaches in programming: Garbage Collection, Manual Memory Management, and Rust's Ownership system.

Automate your blogging workflow by syncing your Obsidian notes directly to Hashnode using the GraphQL API and a Python script.
This is what a normal HTTP request looks like: https://www.google.com/api/search?q=home
Let's break it down:
| Component | Description |
|---|---|
https | Scheme used to tell the browser which protocol to use while connecting |
www.google.com | Domain to which we want to connect |
/api/search | Path to the resource on the website we are accessing |
?q=home | Optional query params to pass additional information in the request |
— URL Structure
When we send the request, it is forwarded to a Domain Name Server that translates the URL to the IP Address of the machine where the website/service is running. Domain names are easier for humans to read and remember, so we use them. With every request, they are translated to their respective IP Addresses.
The browser does a DNS lookup to get the associated IP Address. When you enter a domain in the web browser address bar, you submit a DNS Request. The resolution process follows this order:
A DNS record is an IP address that matches the fully-qualified domain name.
— DNS Hierarchy
If not found in any cache, a DNS query or a request to a network of 4 DNS Servers is made. These servers include:
Its purpose is to forward a request to other domain name system servers and then send it back. When a request is received, it searches its cache. If not found, it is forwarded to the Root nameserver.
It identifies the Top-Level Domain and tells the DNS resolver to go to the correct TLD nameserver. There are exactly 13 Root Nameserver IPs managed by 12 different organizations globally, each with multiple servers to process incoming requests.
It informs the resolver about the location of the IP address at a specific authoritative nameserver.
It stores all information related to the domain name you want to visit in the form of zones, including its IP address. This IP is then cached and sent back to the user.
After the resolution, the browser gets the IP address to connect to. It then:
— TCP Connection
The browser then compiles the request into HTTP specifications. A typical HTTP request packet looks like this:
GET /api/search?q=home HTTP/1.1
Host: www.google.com
User-Agent: Mozilla/5.0
Accept: text/html
Connection: keep-aliveCommon HTTP verbs include:
| Verb | Description |
|---|---|
GET | Fetch data without body |
POST | Send data in the request body |
PUT | Update existing resource |
DELETE | Remove resource |
The request is then parsed by the server to understand what needs to be done. It can be fetching data from the database, performing some calculations, or loading some files to send back.
A typical HTTP response looks like:
HTTP/1.1 200 OK
Cache-Control: max-age=3600
Content-Type: text/html
Content-Length: 1023
Set-Cookie: session=abc123
<!-- Content Body -->| Range | Category | Examples |
|---|---|---|
| 2xx | Success | 200 OK, 201 Created |
| 3xx | Redirection | 301 Moved Permanently, 302 Found |
| 4xx | Client errors | 400 Bad Request, 404 Not Found |
| 5xx | Server errors | 500 Internal Server Error, 503 Service Unavailable |
The browser then parses the messages, extracts the information, and renders it on the Browser or Terminal. In case the browser can't render the document directly, it downloads it (like PDFs or other documents).
If the HTML contains CSS files, images, or JS code, subsequent requests are made to fetch these and render them on the browser.
When you enter a URL in your browser, several steps occur: