What Happens When You Type google.com in Your Browser and Press Enter
--
Websites are collections of files that instruct your browser how to display the site, images, and data. These files frequently include HTML, CSS, Javascript, and images. Hosting them on your computer at home isn’t scalable or reliable because they need to be reachable by anybody, from anywhere, at any time. These files are kept on a server, an extremely capable external computer linked to the Internet.
Your browser must determine which Internet server is hosting the website when you point it at a URL like google.com. It accomplishes this by locating the address by searching the domain, google.com.
An IP address is used to identify any device on the internet.
DNS emerged together with the development of domain names. DNS is comparable to our phone’s Contacts app. Our browser uses DNS to locate servers on the Internet. Using the domain name google.com as a foundation, we can perform a DNS lookup to determine the IP address of the server.
Breaking parts of URL
We have been referring to our demo URL up to this point as google.com, but in reality, it has a hidden portion that is requested to be autocompleted by your search. The full URL is displayed as https://google.com.
Let’s examine the URL in more detail. The scheme is at https://. Hypertext Transfer Protocol Secure is known as HTTPS. With the help of this protocol, the browser is instructed to connect to the server utilizing Transport Layer Security (TLS). TLS is an encryption system used to protect online communications. Your browser and the server exchange encrypted data over HTTPS, including passwords, credit card numbers, and other sensitive information. Additionally, you might have seen ftp:/, mailto:/, or file:/. Browsers are able to handle these additional protocols.
The website’s domain is google.com, which comes after that. Its distinctive moniker directs users to the 172.217.170.174 server.
After the domain, some URLs have additional content. The server route to the requested resource, for instance, is https://dearlydebbie.tech/hello-world. The path on your computer can be compared to the directory structure of your computer’s files and other directories. Whether they are static HTML, CSS, Javascript, image files, or dynamically generated material, it’s a way to arrange your resources.
We now know that the browser will search for the domain’s IP address when you type google.com and hit Enter. How will the procedure proceed?
How does the browser lookup an IP address for the domain?
After you’ve typed the URL into your browser and pressed enter, the browser needs to figure out which server on the Internet to connect to. To do that, it needs to look up the IP address of the server hosting the website using the domain you typed in. It does this using a DNS lookup. You can read more about how DNS works here.
Because DNS is complex and has to be blazingly fast, DNS data is cached at different layers between your browser and various places across the Internet. Your browser checks its cache, the operating system cache, a local network cache at your router, and a DNS server cache on your corporate network or at your internet service provider (ISP). If the browser cannot find the IP address at any of those cache layers, the DNS server on your corporate network or at your ISP does a recursive DNS lookup. A recursive DNS lookup asks multiple DNS servers around the Internet, which in turn ask more DNS servers for the DNS record until it is found.
Once the browser gets the DNS record with the IP address, it’s time for it to find the server on the Internet and establish a connection. How is this connection established?
How does the browser initiate a TCP connection with the server?
Using the public Internet routing infrastructure, packets from a client browser request get routed through the router, the ISP, through an internet exchange to switch ISPs or networks, all using transmission control protocol (TCP) to find the server with the IP address to connect to at port 443. Once the browser has established a connection with the server, a Secure Socket Layer (SSL) certificate is generated to denote the domain as secured. The next step is to send the HTTP request to get the resource or the page. How is the request made?
How does the browser send HTTP requests to the server?
Now that the browser has a connection to the server, it follows the rules of communication for the HTTP(s) protocol. It starts with the browser sending an HTTP request to the server to request the contents of the page. The HTTP request contains a request line, headers (or metadata about the request), and a body. The request line contains information that the server can use to determine what the client (in this case, your browser) wants to do.
The request line contains the following:
a request method, which is one of GET, POST, PUT, PATCH, DELETE, or a handful of other HTTP verbs
the path, pointing to the requested resources
the HTTP version to communicate with
For a broader explanation, see here. So what happens after the server has received the client’s request?
Server process request and sends a response to client
The server takes the request and based on the info in the request line, headers, and body then decides how to process the request. It fetches the requested content from the available database.
The response contains the following:
a status line, telling the client the status of the request
response headers, telling the browser how to handle the response
the requested resource at that path, either content like HTML, CSS, Javascript, or image files, or data
Resources can be static files, either text (HTML files) or non-text data (images). Browsers aren’t always requesting static files, though. Often, these are dynamic resources generated at the time of the request and there is no file associated with the resource. The browser renders the content afterwards.
How the browser renders content
Once the browser has received the response from the server, it inspects the response headers for information on how to render the resource. The Content-Type header above tells the browser it received an HTML resource in the response body.
Sometimes, there is a lot of traffic of clients requests to servers (you are typing google.com, other people are typing so much more). To improve the efficiency of servers and reduce loading time, a load balancer is used.
Introduction to load balancer
A load balancer intelligently distributes traffic from clients across multiple servers without the clients having to understand how many servers are in use or how they are configured. Because the load balancer sits between the clients and the servers it can enhance the user experience by providing additional security, performance, resilience and simplifying scaling your website.
Load balancers perform many functions in addition to just splitting traffic across servers, among them are: HTTP reverse proxy, Traffic and routing optimisation algorithms, Image caching (reducing web server load), Content caching
Your request to view google.com will be equally balanced with all other available requests from other clients. The load balancer will allocate a server for you.
Now that you know how requests are balanced using a load balancer, let’s see something else. How can you prevent unauthorized access to your website?
Introduction to firewall
A firewall is a security device — computer hardware or software — that can help protect your network by filtering traffic and blocking outsiders from gaining unauthorized access to the private data on your computer.
Not only does a firewall block unwanted traffic, but it can also help block malicious software from infecting your computer.
Firewalls can provide different levels of protection. The key is determining how much protection you need.