What happens when the browser enters the url?

What happens when you enter a url in the browser address bar?


我们在浏览器输入的url实际上还不能找到服务器对应的地址,这些由字母组成的url只是方便我们记忆而已,实际上每个网址都会有对应的ip地址,而ip地址是由数字组成的不方便我们记忆,所以这里我们需要进行DNS解析


step1: DNS 解析
The process of parsing a URL into an IP address is called DNS resolution.

Insert image description here
In fact, DNS is a database that records many URLs and corresponding IP addresses, so that everyone can find the corresponding IP address based on DNS. With the IP address, we can find the designated server on the Internet.


step2: tcp连接
Although we know the IP address, we still have to establish a tcp connection before officially sending data; establishing a tcp connection means establishing a channel before sending data. Once the client and server establish a channel, they can send data in this channel. Everyone Send data in this channel so that the data is not easily confused.

tcp连接---三次握手:

Insert image description here


step3: 解析请求并响应数据

When we establish a connection with the server, the browser will send an http request message to the server. The format of the message consists of request line, request header, blank line, and request body.

Insert image description here

When the server receives the http request message, the server will process the request message and respond. The response message is very similar to the request message and consists of a status line, response header, blank line and response data.

Insert image description here


step4: 渲染结果

After the browser receives the response from the server, the page will start rendering, that is, parsing the received html, css, js and other files. With these files, the user can see the page content on the front end, that is, in the browser I saw the content inside.

Guess you like

Origin blog.csdn.net/qq_49472679/article/details/127034530