Ever wondered what actually happens when you type a url in browser?
I think this is a very common query which lingers around in our mind everytime we type a url in browser.
So today am gonna briefly discuss about what happens when you type a url in browser.
You enter a url in to the browser. It all starts here.
Basically whenever we want to connect to a particular server, for example lets consider google.com. Here we actually want to reach out a server where google web services are hosted. As an example i have given one such server, as google has around one million servers in various locations.
The browser looks up the IP address for the domain name. DNS server which i would call a resolver does look up to find the IP address of the server.
DNS lookup proceeds by:
– First checking Browser cache
– If the browser doesn’t contain the record in its cache. It makes a system call to the underlying operating system to fetch the record
– If that also fails, then the search continues to your router which has its own cache
– If everything fails, then the search moves on to ISP. It first tries in its cache, if not found then ISP’s DNS recursive search comes into picture
So the domain name which you have entered gets converted into the DNS number.
After which the browser initiates a TCP connection with the server and sends a HTTP GET request. Now the web server passes on the request to the proper request handler which will return a HTML response in our case.
This HTML data stream response is then sent back to the browser. Now browser recieves the HTTP response and then browser displays the HTML content. In our case its the google web page.
Rendering of HTML content is done in phases. It first gets HTML structure and then sends multiple GET request to fetch links and other stuff. And there is a lot more after this. And yeah this is just a outline on what happens when you type a url.
Hope you found this post helpful 🙂