当前位置:网站首页>Common interview questions: Browser input domain name and open the completed process
Common interview questions: Browser input domain name and open the completed process
2022-06-09 07:18:00 【Ah, SEI】
Interview answer :
1. Enter the domain name in the browser address bar
2.DNS analysis IP
3. Sending http Before request , to DNS Domain name resolution , Get access to IP Address
4. Browser sends... To server tcp Connect , Build with browser tcp Three handshakes
5. After a successful handshake , Browser to server http request
6. Server receives request , Process and return the response
7. The browser received the server HTTP Response content
8. Browser rendering , analysis HTML Generate DOM Trees , analysis CSS Generate rule tree ,js Engine parsing js
9. Rendering complete , Four waves , close tcp Connect
Detailed instructions :
One 、DNS Domain name resolution IP Address
1. First look in the browser cache IP, Because browsers cache DNS Record a period of time
2. If not found , And then find the operating system
3. If not found , Then search from the router cache
4. If not , Again from ISP DNS Cache lookup
5. If we don't find any , Browser domain name server to the root domain >COM Top-level domain > The secondary domain
Two 、TCP Three handshakes ,( according to ip establish TCP Connect )
The first handshake : The client sends a... To the server SYN message , And indicate the initialization serial number of the client ISN. At this time, the client is in SYN_Send state .
The second handshake : The server received... From the client SYN After the message , Will take their own SYN Message as reply , And it also specifies its own initialization sequence number ISN(s), At the same time, the client will ISN + 1 As ACK Value , Indicates that you have received the SYN, The server is in SYN_REVD The state of
The third handshake : Client received SYN After the message , Will send a ACK message , Of course , It's the same with the server ISN + 1 As ACK Value , Indicates that the server has received SYN message , At this time, the client is in establised state
Server received ACK After the message , Also in establised state , here , Both sides have established a link to
3、 ... and 、HTTP Request sent to server
The request line includes : Request method ,URL, Protocol version ; for example :GET + Space + /xxxxx/login.html + Space + HTTP/1.1
Request header field :
Cookie: The client can bring data to the server through this header , This is one of the most important request headers .
User-Agent:User-Agent The content of the header field contains the requested user information .
Accept: Browser acceptable MIME type .
Accept-Charset: Browser acceptable character set .
Accept-Encoding: The data encoding method that the browser can decode
Accept-Language: The kind of language the browser wants
Authorization: Authorization information , It usually appears in... Sent to the server WWW-Authenticate In the head's reply .
Content-Length: Indicates the length of the request message body .
Host: The client tells the server through this header , Host name you want to access .Host The header field specifies the Intenet Host and port number , A request must be made url Location of the original server or gateway .HTTP/1.1 The request must contain the host header domain , Otherwise, the system will use 400 Status code returns .
Four 、 Server processing request , Browser accepts HTTP Respond to
The response line is defined by the protocol version 、 The state code and its description are composed of ; Such as :HTTP/1.1 200 OK
The protocol version HTTP/1.1 perhaps HTTP/1.0,200 It's the status code ,OK Is its description .
Common status codes are as follows :
1xx: Indicates that the server has received a client request , The client can continue to send requests ;
2xx: Indicates that the server has successfully received the request and processed ;
3xx: Indicates that the server requires client redirection ;
4xx: Indicates that the client's request has illegal content ;
5xx: Indicates that the server failed to properly process the client's request with an unexpected error , Server error ;
The status code description text has the following values :
200 OK: Indicates that the client request is successful ;
400 Bad Request: Indicates that the client request has a syntax error , Not understood by the server ;
401 Unauthonzed: Indicates that the request is not authorized , The status code must be associated with WWW-Authenticate Header fields are used together ;
403 Forbidden: Indicates that the server received a request , But refused to provide service , The reason why the service is not provided is usually given in the response body ;
404 Not Found: Requested resource does not exist , for example , I typed the wrong one URL;
500 Internal Server Error: Indicates that an unexpected error occurred on the server , The client's request could not be completed ;
503 Service Unavailable: Indicates that the server is currently unable to process the client's request , After a period of time , The server may return to normal ;
5、 ... and 、 Page rendering , structure DOM Trees
1、 The server processes through the background language program , Find the data and return it to the browser
2、HTML The string is read and parsed sentence by sentence after being accepted by the browser , Resolved to link Tag and resend the request to get css
3、 Resolved to sript After the tag, send a request to get js, And execute the code , The browser will render
4、 Browser according to HTML and CSS Calculate the rendering tree , Draw on the screen ,js Will be performed
5、 After parsing DOM Trees and CSS The rule tree is associated to build the rendering tree , Calculate layout , Draw page
6、 ... and 、TCP Four waves ( disconnect )
First wave : The client sends one FIN message , A serial number... Will be specified in the message . At this time, the client is in FIN_WAIT1 state .
Second wave : Server received FIN after , Will send ACK message , And the client's serial number value + 1 As ACK The value of the message's serial number , Indicates that a message has been received from the client , At this time, the server is in CLOSE_WAIT state .
Third wave : If the server wants to disconnect too , Same as the first wave of the client , issue FIN message , And specify a serial number . At this time, the server is in LAST_ACK The state of .
Fourth wave : Client received FIN after , Send a ACK Message as reply , And the server serial number value + 1 As myself ACK The value of the message's serial number , At this time, the client is in TIME_WAIT state . It will take a while to ensure that the server receives its own ACK The message will enter after CLOSED state .
Server received ACK After the message , It's closing the connection , be in CLOSED state
边栏推荐
- On database optimization (taking MySQL as an example)
- 招聘 | 上班轰趴,下班狼人杀,天天招人,怕是要发!
- Application and analysis of special cases of data visualization
- Talk about the ten mistakes often made in implementing data governance
- LVS+keepalived高可用
- Use of thread pool
- Matlab: difference between tf2zp and tf2zpk
- 政务大厅导航系统功能解读
- [C language] summary of document knowledge points
- UML series articles (25) high level behavior - state diagram
猜你喜欢

Squid代理服务器应用

2022年最新山西建筑安全员模拟题库及答案

Error (119013): current license file does not support the ep4ce10f17c8 device solution

Flutter learning Hello World
![[untitled]](/img/af/4d7370b72b0f558d5c8cd194c4ae3d.png)
[untitled]

LVS+keepalived高可用

100 code structure and how to avoid them (4)

In the afternoon of July 2, 2022, Jinan IT technology gathering, interested friends scanned the code to sign up for group exchange

Database operation statement

UML series article (22) advanced behavior -- state machine
随机推荐
Use postman to simulate a request to carry a token
如何解决低代码平台中的安全问题?
100 code structure and how to avoid them (4)
Solution to display < unknown > when Charles grabs packets in win system
新职业:数字化管理师太抢手,只要来面试,企业就会发offer
[NewOJ Week 1]---CDE
Distributed message middleware -- Introduction to message queue
Basic knowledge summary of database
外设驱动库开发笔记42:DAC8552 DAC驱动
Talk about the ten mistakes often made in implementing data governance
Flutter学习之Hello World
PostgreSQL database replication - background first-class citizen process walreceiver extracts information
UML series articles (25) high level behavior - state diagram
10. 正则表达式匹配
大厂面试算法系列-动态规划求解最长公共子串问题
线程池的使用
In the afternoon of July 2, 2022, Jinan IT technology gathering, interested friends scanned the code to sign up for group exchange
How idea views the path to save code
Which software design documents are most easily ignored?
Naive Bayes classifier