DEV Community

Cover image for ๐ŸŒ What Really Happens When You Type a URL into Your Browser?
Aditya Pandey
Aditya Pandey

Posted on

๐ŸŒ What Really Happens When You Type a URL into Your Browser?

Ever wondered whatโ€™s happening behind the scenes when you type something like example.com/phone into your browser and hit Enter? Letโ€™s break it down:


๐Ÿ”น Step 1: Entering the URL

Bob types a URL into the browser. A URL typically has four parts:

  • Scheme: http:// โ†’ tells the browser to use HTTP protocol
  • Domain: example.com โ†’ identifies the server
  • Path: /product/electric โ†’ specifies the resource location
  • Resource: phone โ†’ the exact item Bob wants to view

๐Ÿ”น Step 2: DNS Lookup

The browser needs the IP address of the domain. It searches through:

  • Browser cache
  • OS cache
  • Local network cache
  • ISP cache

If the IP address isn't found, a recursive DNS lookup is triggered (weโ€™ll dive deeper into this in another post).


๐Ÿ”น Step 3: Establishing a TCP Connection

With the IP address in hand, the browser sets up a TCP connection to the server.


๐Ÿ”น Step 4: Sending the HTTP Request

The browser sends a structured HTTP request asking for the /phone resource under the domain example.com.


๐Ÿ”น Step 5: Receiving the HTTP Response

The server processes the request and sends back an HTTP response.

If successful (status code 200 OK), it includes the requested HTML content like:

Hello world
Enter fullscreen mode Exit fullscreen mode

๐Ÿ”น Step 6: Browser Renders the Page

Finally, the browser takes the HTML and renders the page so Bob can see and interact with it.


๐Ÿ” Key takeaway:

Typing a URL triggers a chain of networking and server events โ€” from DNS lookups to TCP handshakes to rendering web pages โ€” all in a blink of an eye!


Top comments (0)