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
How does CDN play a role here ? I believe it comes between step 5 and 6. Can you elaborate here a bit..
I was recently asked on this. Does ARP involves in this process too? Or with the IP address found by DNS is sufficient enough?