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
DNS Resolution
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:
- The operating system's DNS cache
- Local hosts file
- Browser cache
- ISP cache
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:
Recursive DNS Resolver
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.
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.
TLD Nameserver
It informs the resolver about the location of the IP address at a specific authoritative nameserver.
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.
TCP Connection
After the resolution, the browser gets the IP address to connect to. It then:
- Establishes a TCP connection with the server
- If HTTPS, performs a TLS handshake for secure communication
- HTTP/3 uses QUIC protocol instead of TCP
TCP Connection
Sending the Request
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 |
Parsing the Request
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 -->Common Status Codes
| 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 |
Rendering the Response
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.
Summary
When you enter a URL in your browser, several steps occur:
- URL Parsing — Protocol, domain, path, query params
- DNS Resolution — Convert domain to IP address (checking caches, querying DNS servers)
- TCP Connection — Establishment with TLS handshake for HTTPS
- HTTP Request — Sending and response handling
- Content Rendering — HTML, CSS, JS processing
