paint-brush
What Happens When You Click a URL: DNS Lookup, TCP Handshake & HTTP Requestby@jaypmedia
302 reads
302 reads

What Happens When You Click a URL: DNS Lookup, TCP Handshake & HTTP Request

by Jean-Paul RustomFebruary 16th, 2024
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

DNS stands for Domain Name System, and it is a huge database where domain names are stored with their corresponding IP addresses You could think of it as the phone book of the internet.
featured image - What Happens When You Click a URL: DNS Lookup, TCP Handshake & HTTP Request
Jean-Paul Rustom HackerNoon profile picture

What Happens When You Type in an Url

Okay, so what happens when JayP clicks on a URL?


How would the internet take him to his desired website?

Servers

Before that, what exactly are websites?


Websites are collections of files, and images, that tell your browser how to display the site.


Hello, thanks for the submission! However, it appears that all of, or the majority of, this article was written by an AI. So, we will have to reject it. If you believe this is a mistake, please let us know!

URL Structure

The URL is an address that shows where a particular page can be found.

The first part corresponds to the protocol used.


A protocol is a set of rules that browsers use for communication over the network.


'https' is the secure version of the HTTP protocol.


The second part, www.jaypland.com, is a domain name.


We use it to reach the server that is responsible for serving the information for that website.

IP

In order for the web page to be retrieved, the URL needs to be translated into an IP address.


Clients interact through IP addresses which are unique identifiers.


The IP tells to which server to connect.


Actually, every device connected to the internet has a unique IP address.

JayP could use the IP address instead of the URL to get content from a website.


But, think of it for a second, it would be impossible to remember the IP addresses of every website!

That's why domain names were invented.


Now, to understand how domain names are converted to IP addresses, we need to talk about DNS.

DNS

DNS stands for Domain Name System, and it is a huge database where domain names are stored with their corresponding IP addresses


You could think of it as the phone book of the internet.


Now, how DNS works is a topic on its own and deserves its separate video, but here is the gist of it.

When JayP clicks on a link, the browser checks its own cache; if the IP is not found, then it will check the operating system cache.


If the browser still cannot find the IP address, it will send a DNS query to the DNS resolver specified in the operating system's network settings, which is by default the ISP’s DNS resolver.

The resolver will check its own cache.


If the IP is still not found at any of those cache layers, the resolver will do a recursive DNS lookup.

A recursive DNS lookup asks multiple DNS servers for the DNS record until it is found.


The authoritative name server is responsible for knowing everything about the domain name.

Finally, the resolver gets the IP address associated with the domain name and sends it back to the browser.

Connection With the Server Using TCP

Now, once the IP address of the server is found, the browser initiates a connection with it using what is called a ‘TCP 3-way handshake.’


If you want to know more about it, we have a separate video explaining the handshake in detail in our YouTube channel.

HTTP

Once the connection is initiated, the browser will send an HTTP Get request to the server to get the webpage.

GET/ jaypland.com

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>JayPLand</title>
    <link rel="stylesheet" href="styles.css">
</head>

<body style="background-color: #00008B;">
    <h1>JayPLand</h1>
    <span>Where every click is an adventure</span>
    <img src="https://cdn.jaypland.com/jayp.png" alt="JayP Logo">
    <script src="script.js"></script>
</body>

</html>

Then, the rendering engine of the browser starts interpreting and displaying the content.


If the page has images or videos, the browser will see this and request that they be brought to the web page as well.


And ta daaa...just like that, the web page has loaded!