A general overview

  1. Synthesis of URL
  2. DNS Domain name Resolution
  3. Establishing a TCP connection (three-way handshake)
  4. The HTTP request is sent, and the server processes the request and returns the corresponding result
  5. Close the TCP connection (four waves)
  6. Browser rendering

User input URL

The browser will synthesize a new URL based on the search engine based on what you type. If the user enters a valid URL, the browser adds a valid protocol to the content based on the URL.

For example, if you type www.baidu.com, the URL bar will combine the content with the protocol according to the rules to synthesize the full URL, such as www.baidu.com

How does the browser use DNS to search for the IP address of a domain name

  1. Browser cache: The browser caches DNS records at a certain frequency.
  2. Operating system cache: If the browser does not find the corresponding cache, go to the operating system.
  3. Route cache: The router also has a DNS cache
  4. DNS server of an ISP: AN ISP has a dedicated DNS server to respond to DNS query requests.
  5. Root server: If the ISP’s DNS server cannot be found, it sends a recursive query to the root server (the DNS server first asks the IP address of the.com domain server, then the.com domain server, and so on).

HTTP Request Process

Knowledge review:

  1. HTTP1.1 differs from HTTP2 in multiplexing.

Multiplexing: Multiple request-response messages are sent from a single HTTP/2 connection request, and multiple request streams share a TCP connection, enabling multiple connections in parallel rather than relying on the establishment of multiple TCP connections. Please refer to the following figure for details

  1. What’s the difference between HTTP and HTTPS?

HTTP: stateless and connectionless. Based on request and response, plaintext is used for communication. Request and response do not confirm the communication party, and data integrity cannot be protected

HTTPS: encrypts data, authenticates peer identities, and protects data integrity over SSL or TLS based on the HTTP protocol. Mixed encryption: The intermediate cannot view the plaintext in the middle. The two parties are encrypted and decrypted by digital certificates to ensure that they will not be stolen or tampered with during transmission.

  1. HTTP and TCP?

The browser uses HTTP as the application layer protocol to encapsulate the requested text information. It uses TCP/IP as the transport layer protocol to send it to the network, so the browser needs to establish a connection with the server over TCP before HTTP work can begin. That is, HTTP content is implemented through the TCP data transfer phase.

Back to HTTP requests

After the DNS obtains an IP address, the port establishes a connection through TCP/IP.

Three handshakes:

Why do you need three handshakes? An error occurs in case an invalid connection request segment is suddenly sent to the server.

For example, the segment of the first connection request packet sent by the client is not lost, but is detained on a network node for a long time. As a result, it is delayed to reach the server until a certain time after the connection is released. This is an invalid connection request segment. However, after receiving the invalid connection request segment, the server mistakenly thinks it is a new connection request sent by the client. Therefore, the server sends an acknowledgement packet to the client and agrees to establish a connection. If the “three-way handshake” is not adopted, a new connection is established as soon as the server sends an acknowledgement. Since the client does not send a request to establish a connection, it ignores the confirmation from the server and does not send data to the server. However, the server thinks that a new transport connection has been established. And wait for the client to send data. Therefore, the “three-way handshake” is not adopted, in which case a lot of server resources are wasted.

Four waves:

Why do you need four waves?

TCP is in full-duplex mode. When a TCP client sends a FIN packet, the client sends a message to the server indicating that all data has been sent. However, the client can still accept the data from the server. When the server returns an ACK packet, it indicates that it knows that no data is sent from the client, but the server can still send data to the client. When the server also sends a FIN packet, the server tells its client that it has no data to send either. If the server receives a FIN packet, the TCP connection is terminated.

Rendering phase

The rendering process carries out page parsing and sub-resource loading of the document. HTML is transformed into DOM Tree (binary Tree similar structure) through HTM parser. CSS is transformed into CSSOM Tree according to CSS rules and CSS interpreter. Form the Render tree (excluding the specific HTML elements and the specific position of elements to draw), calculate the specific width and height color position of each element through Layout, combine them, start drawing, and finally display them in a new page on the screen.

Refer to the article

www.cnblogs.com/geaozhang/p… Juejin. Cn/post / 684668… Juejin. Cn/post / 684490… Juejin. Cn/post / 684490…