What happens when you visit a website?

Tram Ho

Question

There was a time when you asked a question: What happens when I visit a website? ? This is also a question I ask myself to find the answer. So this article will provide a simple overview of what happens when we open a website on a phone or a computer. Now let’s find out ?

How a website works

Client and Server models

The Client-Server model is a well-known model in computer networks, is widely applied and is the model of every existing website. The idea of ​​this model is that the client (as a client) sends a request (server) to the server (as the service provider), the server will process and return the results to the machine. guest. Here is a simple diagram of how they interact with each other:

  • Clients are network devices of Internet users (for example, your computer or phone) and network software on those devices (For example, a browser such as firefox, chrome, Safari , ..etc ..).
  • Servers are computers that host web pages or applications. When a device from a client wants to access a web page, a copy of the web page is downloaded from the server to the client to display in their browser.

Other ingredients

The above Client-Server not able to fully state the entire operation of the website. There are many other related sections below.

Now imagine a website is a path. At the top of the road is the client like our house for example. On the other end of the street is a server like Vinmart, for example, there will be something you want to buy.

  • Internet connection : Allows you to send and receive data on the web. With the above example, it is a simple way to connect the road between your home and Vinmart.
  • TCP / IP : The TCP/IP can be thought of as a set of layers, each layer resolving a set of problems related to data transmission, and providing top layer protocols with one. The service is clearly defined based on the use of services by the lower levels. Logically, the upper layers are closer to the user and work with more abstract data, they rely on lower-level protocols to transform data into forms that can eventually be transmitted in a material way. physical. Or simply understand that the communication protocols determine the data to be transmitted via the web. This is like a shipping mechanism to allow you to order or go to a Vinmart store to buy what you want. In our example, this would be understood as a motorbike, bicycle, car or walk ?
  • DNS : Is a system that allows the corresponding settings between IP addresses and domain names on the Internet. When we enter the web address in our browser, the browser will look at DNS to find the IP address corresponding to that domain name before accessing the website. From there it will send an HTTP message to the correct server of that site. This is like finding the right address of Vinmart for you to buy things.
  • HTTP : HyperText Transfer Protocol is one of the five standard protocols of the Internet, used to communicate information between the service provider (Web server) and the service user (Web client) in the Client / Server model used for World Wide Web-WWW. It is the application layer protocol and year over TCP / IP. Like the language of communication we use to make purchases at Vinmart.
  • Component files : A website is made up of many different files, and there are two main types: Code files (components that build websites like HTML, CSS, JS, PHP, …), Assets (for example, images, videos, documents, …). Like the different items we buy at Vinmart.

So what exactly happened?

  1. When accessing the website, the browser will call the DNS server to translate the website URL into an IP address, each website has a unique IP address. When the IP address of the website we are visiting is found, that IP address will be returned to the browser.
  2. The browser will use that IP address to request HTTP calls to the server hosting the website. It will connect port number 80 on the Server using TCP / IP.
  3. If the server accepts, it will return a “200 OK” message. And then the browser will retrieve the HTML of the requested site.
  4. When your browser receives that HTML code from the Server, it will display the browser window of a complete web page – awesome!
  5. When we close the browser, the connection with the server will end.

Conclude

So as above we have come to understand the simple view of how a website works. From entering a website into the browser until it shows it to us. But deep down there is a lot of other work to handle when there is a request request. And we will learn gradually, thank you for helping me learn about it. The article may be sketchy and hope you share it with me so I can learn more. See you in the next article!

References: https://en.wikipedia.org https://developer.mozilla.org https://www.programmerinterview.com/networking/what-happens-when-you-visit-a-website/

Share the news now

Source : Viblo