What happens behind the scene when you write “Linkedin.com” until this website content is shown to you?
this is one of the most common interview questions for a web developer position, in fact, this article will not only help you pass an interview question it will make you a better software engineer by understanding how things work behind the scene because having an understanding of HTTP life cycle, allow you to have better control on dealing with HTTP requests and handling them, the answer to this question is full of many details, but I will answer it in a simple way without going into the deep details.
1: type your URL
let's say that you are going to type “Linkdin.com”, everything starts after you press enter.
2: Cache checking process
the browser checks the cache for a DNS record to find the IP address of Linkdin.com.
and to make everything simple DNS (Doman Name System) you can imagine it like your first name is the URL and your full name from four syllables is the IP address
DNS has the URL (linkdin.com) and the IP address for example (http://205.65.227.101), so DNS makes it easier to reach your website by typing only the URL
3: the URL is not in the cache!
If the requested URL is not in the cache, ISP’s DNS server initiates a DNS query to find the IP address of the server that hosts Linkdin.com, this process called the recursive search; because thee search will repeatedly continue from a DNS server to a DNS server until it finds the IP address we need and grab the correct IP address, and come back to your browser.
4: initiation TCP connection
after grabbing the correct IP address, it's time to transfer information.
transferring data happens through a process called the TCP/IP three-way handshake.
after the TCP/IP three-way handshake is done, now it's time to transfer data.
5: your browser will send an HTTP request to the webserver that has the correct IP address
your browser will send a GET request asking for Linkdin.com
the request will contain some information like this pic
6: handling the request and sends back a response
The response has formats like JSON, XML, HTML.
the response will contain information like this pic
7: displaying the content
your browser will render the content in steps
the first thing HTML then sends out GET requests for additional elements such as images, CSS, JavaScript .. etc.