What happens when you type https://www.mywebsite.com in your browser and press Enter?

If we want to know what happen, we should talk about Domain Name.

What is a Domain Name?

Domain name is the address of your website that people type in the browser URL bar to visit your website.

Hypertext Transfer Protocol Secure HTTPS:

Is an extension of the Hypertext Transfer Protocol (HTTP). It is used for secure communication over a computer network, and is widely used on the Internet. In HTTPS, the communication protocol is encrypted using Transport Layer Security (TLS) or, formerly, Secure Sockets Layer (SSL).

World Wide Web www:

Technically, it’s a subdomain traditionally used to indicate that a site is part of the web, as opposed to some other part of the Internet like Gopher or FTP.

.com TLD:

The domain name com is a top-level domain (TLD) in the Domain Name System of the Internet. Added in 1985, its name is derived from the word commercial,[1] indicating its original intended purpose for domains registered by commercial organizations. Later, the domain opened for general purposes.

Domain Name System DNS:

is a hierarchical and decentralized naming system for computers, services, or other resources connected to the Internet or a private network.

Transmission Control Protocol/Internet Protocol TCP/IP:

is a suite of communication protocols used to interconnect network devices on the internet. TCP/IP can also be used as a communications protocol in a private computer network (an intranet or extranet).

Firewall:

A Firewall is a network security device that monitors and filters incoming and outgoing network traffic based on an organization’s previously established security policies. At its most basic, a firewall is essentially the barrier that sits between a private internal network and the public Internet. A firewall’s main purpose is to allow non-threatening traffic in and to keep dangerous traffic out.

  • Weighted round robin
  • Least connections
  • Least response time

Web Server:

A web server is hardware or software through which a computer can host a website. A server can be hosted in kernel mode or user mode; kernel mode has the web server run on top of the operating system, while user mode (downloaded just like another app or program) is slower and less effective. Just one example of a well-known web server is Apache, which runs well on a variety of popular operating systems.

Load balancer:

A load balancer is a device that acts as a reverse proxy and distributes network or application traffic across a number of servers. Load balancers are used to increase capacity (concurrent users) and reliability of applications. They improve the overall performance of applications by decreasing the burden on servers associated with managing and maintaining application and network sessions, as well as by performing application-specific tasks.

Application Server:

Application Server is a type of server designed to install, operate, and host applications. In the early days of application servers, there was a huge growth in the number of applications brought to the Internet. Those applications became bigger and bigger with the demand for adding more and more functionalities to the application and become more complex to run and maintain. There was a need for some kind of program on the network while it will share application capabilities in an efficient and organized manner.

Database:

Also called electronic database, any collection of data, or information, that is specially organized for rapid search and retrieval by a computer. Databases are structured to facilitate the storage, retrieval, modification, and deletion of data in conjunction with various data-processing operations. A database management system (DBMS) extracts information from the database in response to queries.

Now what happens when you type https://www.mywebsite.com?

1. You enter the URL in the browser.

Suppose you want to visit the website of www.mywebsite.com So you type www.mywebsite.com in the address bar of your browser. When you type any URL you basically want to reach the server where the website is hosted.

2. The browser looks for the IP address of the domain name in the DNS(Domain Name Server).

DNS is a list of URLs and their corresponding IP address just like the telephone book has phone numbers corresponding to the names of the people. We can access the website directly by typing the IP address but imagine remembering a group of numbers to visit any website. So, we only remember the name of the website and the mapping of the name with the IP address is done by the DNS.

  1. Check OS Cache: If the browser doesn’t contain the cache then it requests to the underlying Operating System as the OS also maintains a cache of the DNS records.
  2. Router Cache: If your computer doesn’t have the cache, then it searches the routers as routers also have the cache of the DNS records.
  3. ISP(Internet Service Provider) Cache: If the IP address is not found at the above three places then it is searched at the cache that ISP maintains of the DNS records. If not found here also, then ISP’s DNS recursive search is done. In “DNS recursive search”, a DNS server initiates a DNS query that communicates with several other DNS servers to find the IP address.

3. The Browser initiates a TCP connection with the server.

When the browser receives the IP address, it will build a connection between the browser and the server using the internet protocol. The most common protocol used is TCP protocol. The connection is established using a three-way handshake. It is a three-step process.

  1. Step 2 (SYN + ACK): If the server is ready to accept connections and has open ports then it acknowledges the packet sent by the server with the SYN-ACK packet.
  2. Step 3 (ACK): In the last step, the client acknowledges the response of the server by sending an ACK packet. Hence, a reliable connection is established and data transmission can start now.

4. The browser sends an HTTP request to the server.

The browser sends a GET request to the server asking for www.mywebsite.com webpage. It will also send the cookies that the browser has for this domain. Cookies are designed for websites to remember stateful information (items in the shopping cart or wishlist for a website like Amazon) or to record the user’s browsing history etc. It also has additional information like request header fields(User-Agent) for that allows the client to pass information about the request, and about the client itself, to the server. Other header fields like the Accept-Language header tells the server which language the client is able to understand. All these header fields are added together to form an HTTP request.

GET /abc.htm HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE5.01; Windows NT)
Host: www.afteracademy.com
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Connection: Keep-Alive

5. The server handles the incoming request and sends an HTTP response.

The server handles the HTTP request and sends a response. The first line is called the status line. A Status-Line consists of the protocol version(e.g HTTP/1.1) followed by numeric status code(e.g 200)and its associated textual phrase(e.g OK). The status code is important as it contains the status of the response.

  1. 2xx: Success: It means the action was successful.
  2. 3xx: Redirection: It means further action must be taken in order to complete the request. It may redirect the client to some other URL.
  3. 4xx: Client Error: It means some sort of error in the client’s part.
  4. 5xx: Server Error: It means there is some error on the server-side.
HTTP/1.1 200 OK
Date: Tue, 28 Jan 2020 12:28:53 GMT
Server: Apache/2.2.14 (Win32)
Last-Modified: Wed, 22 Jul 2019 19:15:56 GMT
Content-Length: 88
Content-Type: text/html
Connection: Closed

6. The browser displays the HTML content.

Now the browser gets the response and the HTML web page is rendered in phases. First, it gets the HTML structure and then it sends multiple GET requests to get the embedded links, images, CSS, javascript files, etc and other stuff. The web page will be rendered and in this case, the afteracademy web page will be displayed.