cheatsheet1999 / FrontEndCollection

Notes for Fullstack Software Engineers. Covers common data structure and algorithms, web concepts, Javascript / TypeScript, React, and more!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

What happens when you type in a URL

cheatsheet1999 opened this issue · comments


  • After we type a URL, the browser will try to find the server’s IP that is related to the URL. First, the browser will look up the cache, and see if there is a record in cache. The order would be from browser cache => system cache => router cache, If there is no record in cache, then the browser will check the “hosts” file in the system. If the record still cannot be found, the browser will check DNS.

  • Second, after the browser gets the server’s IP, the browser will send a HTTP request based on that IP and port. The HTTP request would be encapsulated in a TCP package. That TCP package will pass the transport layer, network layer, data link layer and physical layer to reach the server.

  • Third, the server will respond to the request and return corresponding HTML to the browser. The reason behind the scene is because HTML is a tree structure, so the browser would build a DOM tree based on that HTML. If encountered javascript when constructing the DOM tree, then the browser will stop building the DOM tree and execute the code. (That’s why JS code should be put after the HTML). The CSSOM tree will be built if we have CSS code, and later on it will combine the DOM tree together.