Simple analysis of user request response process
in Note with 0 comment
Simple analysis of user request response process
in Note with 0 comment

The time spent in the process from the browser sending an HTTP request to a specific URL to the browser receiving the return result from the server is the user's request response time.

The request process can be divided into four stages:
1. Establish connection;
2. Send request;
3. Return response;
4. Close the connection.

As shown in the figure below:
 789745642123123146549999999.png

The request process looks simple and often completes instantaneously, but it goes through many steps in the actual implementation. The whole process can be divided as follows:

1. Blocking time: including all preprocessing time. For example, the time of cache searching and waiting for network connection.
When the browser sends an HTTP request to the server, the browser will first find out whether there are resources already needed in the cache. If the required resources exist in the cache and are available, the resources in the cache are used to avoid an HTTP request; If the required resources do not exist in the cache, you need to connect to the server. Under the HTTP/1.1 protocol, the network connection needs to wait in line until the network connection is available, which causes the time consumption of waiting for the network connection. When we browse a website with multiple images, the images are still waiting for the connection to be available.

2. Connection Time: refers to the time taken to create a TCP connection to the server or proxy server.
Before the HTTP work starts, the Web browser must first establish a connection with the Web server through the network. The connection is completed through TCP. HTTP is an application layer protocol at a higher level than TCP. Because of the rules, connections to higher layer protocols can only be made after the bottom layer protocol connection is established. Therefore, you need to complete the establishment of a TCP connection first. Generally, the port of a TCP connection is 80. If an HTTPS secure connection is to be established, an SSL handshake process is also required. At this time, the Keep Alive connection will be frequently used to save the request connection to avoid repeated connection establishment.

3. Sending Time: the time when the HTTP request was sent to the server.
The length of time depends on the amount of data sent by the request. For example, using POST will take a long time to send.

4. Waiting time: refers to the idle time spent waiting for server response messages.
This value includes network latency and server processing time, and it cannot be reduced by front-end optimization methods.

5. Receiving Time: refers to the time spent reading response messages from the server.
This value will be affected by such factors as the size of the message content returned from the server, network bandwidth, and whether HTTP compression is used.

6. Cache read: refers to the time spent reading content from the browser cache or 304 response.
304 The response is associated with a conditional GET request. If the client has completed a conditional request and the request is allowed, but the file has not changed, the server should return 304 status code. 304 The status code must not contain the information subject. It usually ends with the first empty line after a header field.

Responses