DEV Community

Cover image for What happens when I type a URL in browser
Deepika Banoth
Deepika Banoth

Posted on • Updated on

What happens when I type a URL in browser

Ever wondered what actually happens when you type a URL in the browser?

I think this is a very common query that lingers around in our mind every time we type a URL in the browser.

So today am gonna briefly discuss what happens when you type a URL in the browser.

You enter a URL into the browser. It all starts here.

Alt Text

Basically, whenever we want to connect to a particular server, for example, let's consider google.com. Here we actually want to reach out to 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.

Alt Text

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 an HTTP GET request. Now the webserver passes on the request to the proper request handler which will return an HTML response in our case.

Alt Text

This HTML data stream response is then sent back to the browser. Now the browser receives the HTTP response and then the browser displays the HTML content. In our case its the google web page.

Alt Text

Rendering of HTML content is done in phases. It first gets HTML structure and then sends multiple GET requests to fetch links and other stuff. And there is a lot more after this. And yeah this is just an outline on what happens when you type a URL.

Hope this helps πŸ™‚

Video on what happens when you type URL in browser. Click to watch

Top comments (2)

Collapse
 
dipakkr profile image
Deepak Kumar

Well Explained πŸ‘πŸ‘

Collapse
 
ckvineethc profile image
vineeth chandran

Nice one. I think, adding how https work in a similar way would be a good continuation to this.