当前位置:网站首页>[web] the process that the browser enters the URL to the page display

[web] the process that the browser enters the URL to the page display

2022-06-21 04:39:00 Elephant_ King

technological process

Generally speaking, it is divided into the following processes

  • NDS analysis : Resolve the domain name to IP Address
  • TCP Connect :TCP Three handshakes
  • send out HTTP request
  • The server processes the request and returns HTTP message
  • The browser parses the rendered image
  • break link :TCP Four waves

What is? URL

URL It is the web address commonly known as my life , Follow the following syntax rules

scheme://host.domain:port/path/filename

The parts are explained as follows

  • scheme - Define the service types of the Internet . Common protocols are http、https、ftp、file
  • host - Define domain host ( Default www)
  • domain - domain name , such as baidu.com.cn
  • port - Port number ( The default is 80 port )
  • path - Routing on server
  • filename - Define documents / The name of the resource

One 、 Domain name resolution (DNS)

DNS The protocol runs in UDP The agreement above , Use port number 53, After entering the web address in the browser , First, domain name resolution , Will be similar to baidu.com Converting to the corresponding domain name is similar to

104.193.88.123

As for why not give a IP Address , It also saves the trouble of parsing , It is because we are more used to memorizing websites through words or letters than numbers , Computers are better at handling numbers , therefore DNS emerge as the times require

How to search by domain name in browser URL Medium IP Well

  • Browser cache : The browser will cache at a certain frequency DNS Record
  • Operating system cache : If the browser cannot find , Go to the operating system ==( Personal understanding is to find the operating system hosts file )==
  • The routing cache : Routers also have DNS cache
  • ISP Of DNS The server :ISP It is the establishment of Internet service providers ,ISP Specialized DNS The server corresponds to DNS request
  • If you can't find , He will want to send a request to the server , Make recursive queries ( First visit the root domain name server .com Domain name server IP Address , And then visit again .baidu Domain name server , And so on )

Two 、TCP Three handshakes

This article

3、 ... and 、 send out HTTP request

After three handshakes , Start sending HTTP Message request
The request message is sent by Request line 、 Request header 、 Request body Three parts
 Insert picture description here

  • Request line : Including the requestor, Ah Fu 、URL、 Protocol version
    • There are eight request methods :GET,POST,PUT,DELETE,HEAD,OPTIONS,TRACE
    • URL
    • Protocol version , Both HTTP Version number
  • Request header : Contains additional information requested , By key word / value Pairs make up one pair per line , By English : separate
  • Request body : It can carry data of multiple request parameters , But not all requests have request data

Four 、 The server processes the request and returns HTTP message

1. The server

For requests sent by different users , Will be combined with the configuration file , Delegate different requests to a program on the server that processes the corresponding requests , Then return the effect produced by the daemon processing as a response

2.MVC Background processing stage

MVC Divide the program into three core components : Model (MODEL)– View (view)– controller (controller)

View

Provide the user with the operation interface , It's the shell of the program

Model

Mainly responsible for data interaction

controller

Responsible for the commands that the user passes in from the view layer , Select the data in the model layer , Then carry out the corresponding operation , Present the final result

3.HTTP response message

The response message is sent by Response line 、 Response head 、 Response subject Three parts
 Insert picture description here

  • The response line contains : Protocol version , Status code , Status code description
    The status code rules can be viewed as This article
  • The response header contains additional information of the response message , from name / value To claim to be
  • The response body contains a carriage return 、 Line breaks and response return data , Not all response messages have corresponding data

5、 ... and 、 The browser parses the rendered image

There are five steps

  • according to HTML It is concluded that DOM Trees
  • according to CSS Parse generation CSS The rule tree
  • combination DOM Trees and CSS The rule tree , Generate render tree
  • Calculate the information of each node according to the rendering tree
  • Draw the page according to the calculated information

6、 ... and 、 break link

Four waves

Reference article
Browser input a url The whole page shows what process it has gone through ?

原网站

版权声明
本文为[Elephant_ King]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202221706523923.html