Do you know, what happen when you type an url and hit enter in your browser?
So maybe today you woke up more curious than usual and want to know what happens when you type any url in the browser? Well, it's your lucky day, I'm going to explain what happens when you put https://www.holbertonschool.com for example and hit enter.
To make a super short summary we can say that there are 8 steps.
And that would be it ... but wait, it would be more interesting if we went step by step with a little more detail, right? Well then, let's do it!
1. You write https://www.holbertonschool.com in the browser's address bar and hit enter.
That's the easy part, right?
2. The browser searches the cache for a DNS record that corresponds to the IP of that url.
DNS (Domain Name System) is a database that maintains the name of the website (URL) and the specific IP address to which it links. Every URL on the Internet has a unique IP address assigned to it. The IP address belongs to the computer that hosts the server of the website that we request to access
The primary purpose of DNS is human-friendly navigation. A website can be easily accessed by typing the correct IP address into the browser, but can you imagine having to remember different sets of numbers for all the sites that we regularly access?
To find the DNS record, the browser checks four caches.
3. If the requested URL is not in the cache, the ISP's DNS server initiates a DNS query to find the IP address of the server hosting it.
The goal of a DNS query is to search multiple DNS servers on the Internet to find the correct IP address for the website. This type of search is called a recursive search, as the search will continue repeatedly from one DNS server to another until it finds the IP address we need or returns an error response saying that it could not find it.
Without confusing you further, I would like to use the following diagram to explain the architecture of the domain.
Many website URLs that we find today contain a third-level domain, a second-level domain, and a top-level domain.
领英推荐
4. Now, the browser initiates a TCP connection with the server.
Once the browser receives the correct IP address, it will establish a connection to the server that matches the IP address to transfer the information. Browsers use Internet protocols to establish these connections. There are several different Internet protocols that can be used, but TCP is the most common protocol used for many types of HTTP requests.
To transfer data packets between your computer (client) and the server, it is important to have an established TCP connection.
5. The browser sends an HTTP request to the web server.
Once the TCP connection is established, it's time to start transferring data! The browser will send a GET request requesting the url of the web page. If you are entering credentials or submitting a form, this could be a POST request. This request will also contain additional information such as the browser identification (User-Agent header), the types of requests it will accept (Accept header), and connection headers that ask you to keep the TCP connection alive for additional requests. It will also pass information taken from the cookies that the browser has stored for this domain.
6. The server handles the request and returns the response.
The server contains a web server (eg Apache, IIS) that receives the request from the browser and passes it to a request handler to read and generate a response. The request manager is a program (written in ASP.NET, PHP, Ruby, etc.) that reads the request, its headers and cookies to check what is being requested and also to update the information on the server. Then it will put together a response in a certain format (JSON, XML, HTML).
7. The server sends an HTTP response.
The server response contains the requested web page, as well as the status code, the compression type (Content-Encoding), the page caching mode (Cache-Control), the cookies to be set, the information about privacy, etc.
There are five types of states detailed by a numeric code.
So if you have encountered an error, you can take a look at the HTTP response to see what kind of status code you have received.
8. The browser displays the content of the url.
The browser displays the content in phases and that's it!
All eight steps, this whole process only takes milliseconds and we don't even realize it.