What Happens When you Type https://www.google.com in Your Browser and Press Enter

What Happens When you Type https://www.google.com in Your Browser and Press Enter

·

4 min read

ALX Blog Post by Joy Celina

When you enter www.google.com into your browser and hit "enter," what exactly occurs behind the scenes? In the same way, I'm certain someone has asked you the same question at some point in your career as a software engineer. If not, it is always beneficial to have a rudimentary awareness of what is happening behind our browsers and how data is delivered to our computers over the internet, regardless of whether you are an engineer, developer, marketing, or even in sales.

The first thing the browser will do when we enter the URL www.google.com and hit Enter divides the URL up into smaller bits. The Google.com portion, which is a domain name, will be taken into account first by the browser.

A database called DNS (Domain Name System) keeps track of a website's name (URL) and the specific IP address it points to. Every URL on the internet has been given a different IP address. The machine that houses the server for the website we are trying to visit is identified by its IP address. For instance, the IP address of www.google.com is 209.85.227.104. So, if you'd like, you may use your browser to get to www.google.com by entering http://209.85.227.104. Similar to how a phone book is a collection of names and related phone numbers, DNS is a list of URLs and their IP addresses.

User-friendly navigation is DNS's main goal. If you know the IP address of a website, you can simply access it, but what if you had to memorize a new set of digits for each website you frequently visit? As a result, it is simpler to memorize the URL instead of the website's name and let DNS handle translating the URL to the appropriate IP.

The browser searches four caches to locate the DNS record.

  1. It first looks at the cache in the browser. For a certain amount of time, the browser stores DNS entries for previously visited domains in a repository. The first location to conduct a DNS query is thus there.

  2. The browser then checks the OS cache. The browser will make a system call to your underlying computer OS (get hostname on Windows) to retrieve the record if it is not already in the browser cache because the OS also keeps a cache of DNS entries.

  3. The router cache is checked third. The browser will speak with the router, which keeps its own cache of DNS records if it is not already on your machine.

  4. The ISP cache is checked fourth. The browser will go on to the ISP if all attempts fail. As a final resort, the browser would examine your ISP's own DNS server, which contains a cache of DNS records, in the hopes of locating the URL you requested.

You might be perplexed as to why there are so many caches kept at so many different levels. Caches are crucial for controlling network traffic and accelerating data transmission rates, even if the idea of our information being stored somewhere makes us feel uneasy about our privacy.

The browser will establish a connection with the server that matches the IP address once it has the right IP address to transmit data. Internet protocols are used by browsers to create these connections. Various internet protocols may be utilized, but TCP is the one that many different kinds of HTTP/SSL requests use the most.

It's crucial to establish a TCP connection to send data packets between your computer (the client) and the server. The three-way handshake in TCP/IP is used to establish this connection. To establish a connection, the client and server exchange SYN (synchronize) and ACK (acknowledge) messages through a three-step procedure.

1. The client computer queries the server over the internet using an SYN packet to see if it is accepting new connections.

2. The server will react by issuing an SYN/ACK packet to acknowledge the SYN packet if it has open ports that may accept and begin new connections.

3. The client will acknowledge receipt of the SYN/ACK packet from the server by sending an ACK packet. After that, a TCP connection is created for data transfer!

A web server on the server—for example, Apache or IIS—receives the browser's request and forwards it to a request handler, who reads it and produces a response. The request handler is a piece of software (created in ASP.NET, PHP, Ruby, etc.) that examines the request, its headers, and cookies to determine what is being asked for and, if necessary, updates the server's database. Then, it will put together a response in a certain format (JSON, XML, HTML).

The HTML material is shown by the browser in stages. It will first render the basic HTML structure. Once the HTML tags have been verified, GET requests for other web page components including photos, CSS stylesheets, JavaScript files, etc. will be sent. The browser stores these static files in its cache so that it won't have to download them again when you visit the website later. In the end, your browser will see https.google.com.