How does a URL work when it is typed in a browser?

How does a URL work when it is typed in a browser?

ยท

2 min read

In this blog, we will discuss what is URL before jumping and trying to understand what happens when you type a URL into your browser.

What is a URL?

A URL (Uniform Resource Locator) is the address of a resource on the web. Each URL points to unique resources on the web. It consists of different parts, such as the scheme, the domain, the port, the path, the parameters, and the anchor. For example:

https://hashnode.com/explore?source=explore_open

What happens when you type the URL in the browser?

When you type the above URL in a browser, your browser needs to find out which server on the internet hosts the resource you are looking for. To do this, it performs a DNS (Domain Name System) lookup, which translates the domain name (hashnode.com) into an IP address (some IP number).

The IP address is a unique identifier for each device on the internet. Your browser then sends a request to the server using the scheme (https/http) and the port (443 or 80 ) specified in the URL. The scheme indicates the protocol that your browser must use to communicate with the server. HTTPS is a secure version of HTTP (Hypertext Transfer Protocol), which is the most common protocol for web pages.

The server receives your request and checks if it has the resource you are asking for. The path (/explore) and the parameters (?source=explore_open) help the server locate the specific resource on its system. The server then sends back a response to your browser with the resource or an error message if something went wrong.

Your browser receives the response and displays the text or message on your screen. The anchor (#summary) tells your browser to scroll to a specific part of the resource, such as a section heading or a paragraph.

This is a simplified overview of what happens when you type a URL in a browser. There are many more details and steps involved in this process, such as redirects, cookies, encryption, etc.

Hopefully, this gives you a basic idea of how URLs work on the web.

ย