ByteByteGo Newsletter

Share this post

What happens when you type a URL into your browser?

blog.bytebytego.com

What happens when you type a URL into your browser?

Alex Xu
Feb 8, 2022
34
1
Share this post

What happens when you type a URL into your browser?

blog.bytebytego.com

What happens when you type a URL into your browser?

The diagram below illustrates the steps.


1. Bob enters a URL into the browser and hits Enter. In this example, the URL is composed of 4 parts:

๐Ÿ”น scheme - http://. This tells the browser to send a connection to the server using HTTP.
๐Ÿ”น domain - example.com. This is the domain name of the site.
๐Ÿ”น path - product/electric. It is the path on the server to the requested resource: phone.
๐Ÿ”น resource - phone. It is the name of the resource Bob wants to visit.

2. The browser looks up the IP address for the domain with a domain name system (DNS) lookup. To make the lookup process fast, data is cached at different layers: browser cache, OS cache, local network cache, and ISP cache.ย 

2.1 If the IP address cannot be found at any of the caches, the browser goes to DNS servers to do a recursive DNS lookup until the IP address is found (this will be covered in another post).ย 

3. Now that we have the IP address of the server, the browser establishes a TCP connection with the server.

4. The browser sends an HTTP request to the server. The request looks like this:

๐˜Ž๐˜Œ๐˜› /๐˜ฑ๐˜ฉ๐˜ฐ๐˜ฏ๐˜ฆ ๐˜๐˜›๐˜›๐˜—/1.1
๐˜๐˜ฐ๐˜ด๐˜ต: ๐˜ฆ๐˜น๐˜ข๐˜ฎ๐˜ฑ๐˜ญ๐˜ฆ.๐˜ค๐˜ฐ๐˜ฎ

5. The server processes the request and sends back the response. For a successful response (the status code is 200). The HTML response might look like this:ย 

๐˜๐˜›๐˜›๐˜—/1.1 200 ๐˜–๐˜’
๐˜‹๐˜ข๐˜ต๐˜ฆ: ๐˜š๐˜ถ๐˜ฏ, 30 ๐˜‘๐˜ข๐˜ฏ 2022 00:01:01 ๐˜Ž๐˜”๐˜›
๐˜š๐˜ฆ๐˜ณ๐˜ท๐˜ฆ๐˜ณ: ๐˜ˆ๐˜ฑ๐˜ข๐˜ค๐˜ฉ๐˜ฆ
๐˜Š๐˜ฐ๐˜ฏ๐˜ต๐˜ฆ๐˜ฏ๐˜ต-๐˜›๐˜บ๐˜ฑ๐˜ฆ: ๐˜ต๐˜ฆ๐˜น๐˜ต/๐˜ฉ๐˜ต๐˜ฎ๐˜ญ; ๐˜ค๐˜ฉ๐˜ข๐˜ณ๐˜ด๐˜ฆ๐˜ต=๐˜ถ๐˜ต๐˜ง-8

<!๐˜‹๐˜–๐˜Š๐˜›๐˜ ๐˜—๐˜Œ ๐˜ฉ๐˜ต๐˜ฎ๐˜ญ>
<๐˜ฉ๐˜ต๐˜ฎ๐˜ญ ๐˜ญ๐˜ข๐˜ฏ๐˜จ="๐˜ฆ๐˜ฏ">
๐˜๐˜ฆ๐˜ญ๐˜ญ๐˜ฐ ๐˜ธ๐˜ฐ๐˜ณ๐˜ญ๐˜ฅ
</๐˜ฉ๐˜ต๐˜ฎ๐˜ญ>

6. The browser renders the HTML content.


If you enjoyed this post, you might like our system design interview books as well.

SDI-vol1: https://amzn.to/3tK0qQn

SDI-vol2: https://amzn.to/37ZisW9

1
Share this post

What happens when you type a URL into your browser?

blog.bytebytego.com
1 Comment
Atanu Mallik
Oct 22, 2022

How does CDN play a role here ? I believe it comes between step 5 and 6. Can you elaborate here a bit..

Expand full comment
ReplyCollapse
TopNewCommunity

No posts

Ready for more?

ยฉ 2023 ByteByteGo
Privacy โˆ™ Terms โˆ™ Collection notice
Start WritingGet the app
Substackย is the home for great writing