A Journey from URL Entry to Web Page Display
Decoding the Web
What is a URL?
A URL, or Uniform Resource Locator, refers to the standardized method of locating resources on the web.
Segments of URL
http:// or https:// - These are the protocols (set of rules) that are being followed while the client & server are communicating and exchanging information with each other.
www - World Wide Web, refers to the global information system that is accessible through the internet, enabling users to access and share information.
example.com - the domain name, which is the name of the website that represents its unique address on the internet, allowing users to find and access it.
/blogs - a sub-directory on a website, typically dedicated to hosting blog posts or articles.
/134345 - a unique identifier for a specific page or content within a website, often representing an individual blog post or article.
So far we understand what is a URL. Now let's dive into the steps involved while reaching the server in the network and get our work done.
Based on the domain name entered, an IP address (unique logical address to locate the server in the network) is fetched using the Domain Name Service (DNS) provided by the Internet service provider.
This is a traditional and naive path. However, in the real world, this is not how it works because before even reaching out to the DNS provided by the ISP, we utilize cached data at multiple places throughout this process.
i.e., Browser cache -> OS cache -> Local Cache -> ISP cache -> ...
If the mapping is not available at any of these cache layers, then we perform a recursive DNS lookup at the server to fetch the IP address.
Upon obtaining the server's IP address, the client initiates a TCP connection using a 3-way handshake to establish a reliable communication channel. To enhance security, the connection is upgraded to HTTPS before making an HTTP request to the server. Within the HTTPS framework, the server engages in an SSL/TLS handshake. Then, the server sends its public key to the client. The client uses the public key to encrypt the session key and sends it back to the server. The server then uses its private key to decrypt the session key. With the session key in place, the client and server can now exchange data securely.
After all these steps, when the server receives the client's request, it processes the request and sends back the response. For a successful response, the status returned is 200 (OK). The response typically contains a status code, headers, and a message body that includes the requested information.
How does the browser know the location of the DNS?
The browser knows the location of the DNS because it is already set by default in the network settings, which allows the browser to access it directly.
Why use domain names while searches are happening through IP addresses?
Because humans can't remember long numbers, we make use of domain names, which are easier to remember and access.