Menu

Earn Premium with Referrals

Invite your friends and earn Premium rewards through our referral program.

See how it works and start inviting friends.

The URL Journey: From Input to Page
CN

The URL Journey: From Input to Page

Master the step-by-step process of what happens when you type google.com in your browser.

This is one of the most common interview questions for software engineers. A complete answer spans multiple layers.

Step-by-Step Breakdown

1. URL Parsing

The browser parses the URL: https://www.google.com/search?q=hello

ComponentExample
Protocolhttps
Domainwww.google.com
Path/search
Query?q=hello

2. DNS Resolution

Browser checks caches: Browser → OS → Router → ISP resolver. If none have it cached, a recursive DNS query resolves www.google.com142.250.190.46.

3. TCP 3-Way Handshake

Browser opens a TCP connection to the server’s IP on port 443: SYN → SYN-ACK → ACK.

4. TLS Handshake (HTTPS)

If HTTPS, the client and server negotiate encryption:

  • Client sends supported ciphers
  • Server responds with certificate (public key)
  • Client verifies certificate against trusted CAs
  • Symmetric session key is exchanged
  • Secure tunnel established

5. HTTP Request

Browser sends an HTTP GET request:

GET /search?q=hello HTTP/1.1
Host: www.google.com
User-Agent: Chrome/...
Accept: text/html

6. Server Processing

The server receives the request, processes it (lookup, query, computation), and generates a response.

7. HTTP Response

HTTP/1.1 200 OK
Content-Type: text/html
Content-Length: 45200

Followed by the HTML body.

8. Browser Rendering

  1. Parse HTML → DOM tree
  2. Parse CSS → CSSOM (CSS Object Model)
  3. Combine → Render tree
  4. Layout → compute positions
  5. Paint → pixels to screen
  6. JavaScript executes (may trigger re-layouts)

9. Additional Requests

The browser parses the HTML and makes additional requests for CSS files, JavaScript, images, fonts, etc. Each may trigger new TCP connections (or reuse existing ones via HTTP/2 multiplexing).

Q: What happens when you type a URL in a browser?

A: (1) DNS lookup resolves the domain to an IP. (2) TCP 3-way handshake establishes a connection. (3) TLS handshake negotiates encryption (for HTTPS). (4) HTTP GET request is sent. (5) Server processes and returns HTML. (6) Browser parses HTML, fetches sub-resources, and renders the page.

Q: Why doesn’t the browser do a DNS lookup for every request?

A: Caching. DNS results are cached at multiple levels — browser, OS, router, ISP resolver — for the duration of the TTL (Time To Live). This reduces latency on repeat visits.

Q: What is the slowest step in this process?

A: Usually DNS lookup (if uncached) and TLS handshake. DNS can take 10-100ms. TLS adds 1-2 round trips. After the connection is established, rendering is fast. This is why HTTP/2 multiplexing and DNS prefetch improve perceived performance.

My Private Notes

Notes are auto-saved locally to this device.