First, URL parsing

Does the browser determine whether the keyword entered is a search content or a URL? If you’re searching for content, the address will also use the browser’s default search engine to synthesize urls with keywords. If the input content conforms to the URL rules, the address bar will add the content to the protocol to synthesize the complete URL.

Browsers parse urls into protocols, network addresses, and resource paths

Second, cache check

The browser sends the URL request to the network process through inter-process communication. After receiving the request, the network process checks whether the local cache resources exist. If yes, the cached resources are directly returned to the browser process. If not, enter the network request process.

Strong cache:

Negotiation cache:

DNS resolution

According to the domain name resolved by the browser, go to the DNS server and search for the external IP address of the server.

The browser provides the DNS cache service. If a domain name has been resolved, the browser caches the resolution result for future query.

TCP three-way handshake

First: The client sends a SYN packet to the server and enters the SYN_send state

Second: The server receives and acknowledges a SYN packet and then sends a SYN + ACK packet to the client.

Third: The client receives the packet and sends an ACK packet to the server. Enter the Established state. The channel is established and the data is transferred formally

If UDP is used, the connection is directly established

5. Data transmission

The browser builds the request header, request line information, appending data such as domain name cookies to the request header, and then sends the constructed request information to the server.

After receiving the request information, the server will generate response data according to the request information and send it to the network process. After receiving the response header and the response row, the network process parses the response header.

redirect

If you find that the status code returned is 301 or 302, you need to redirect according to the address of the request header location

Response data type processing

After processing the jump information, the browser differentiates between a download type and a normal HTML page based on the Content-Type field. If it is a download type, the request is submitted to the browser’s download manager and the request ends there. If it is an HTML page, then you need to enter the ready render process

Prepare the render process

By default, Chrome prepares a process for each page; But if you open a new page from one page, and both pages are under the same site, the new page will reuse the parent page’s rendering process.

Submit the document

When the browser process receives a request from the renderer to submit a document, it cleans up the old document and sends a message to the renderer confirming the request. At the same time, the browser process updates the browser interface state, including the security state, the URL of the address bar, the forward and backward historical state, and the Web page

Six or four waves

Wave four times to close the tunnel

Page rendering

Build a dom tree

Style calculation

Convert CSS to a styleSheet file that the browser recognizes. Converting the attribute values in the table to standardize them; Calculate the position of each node in the DOM tree

layout

Create a layout tree; Layout calculation;

layered

Layer to draw

Raster operation

Composition and display