Received from the browser to show a url, to the final page, the process of experience:

Received from the browser to show a url, to the last page, which has gone through what process? What agreements will use it?

Original connection: https://blog.csdn.net/ZHLittleRed/article/details/82947330#1_DNS_3

 

   1, enter the URL in the browser address bar

   2, DNS DNS, obtain the domain name corresponding to the IP address.

Specifically what is DNS?
DNS (Domain Name System) is a "Domain Name System" abbreviation, is an organizational computer systems and network services naming hierarchy into domains, which for TCP / IP network, the service it provides is for the host name and domain name into an IP address of work. DNS is such a "translator", its basic principle can be used to represent the figure below

 

 

         When we entered as www.baidu.com in the browser, in fact, the names of these websites are micrograms simplify people's memories named, in fact, the computer does not know this stuff. Browser only know the IP address, so when enter the domain name address, the browser will first whether there is a corresponding domain name from the browser cache, IP correspondence relationship, if then sends a request to the IP address, if not then the system cache - routing cache lookup, if not, go to the DNS server to find IP.

    3, the browser initiates a TCP connection to a server, establish a TCP three-way handshake with the browser

    4, the browser sends an HTTP request to the server, the request packet

        After establishing a connection with the server, you can initiate a request to the server. HTTP request process is to build an HTTP request message and sent to the server through a specified TCP port protocol (HTTP protocol 80/8080, HTTPS protocol 443). HTTP request is composed of three parts: the request line, request headers and the request body.

    5, the server processes the request received

        After the server receives the request, by the web server (HTTP server should be precisely) processing the request, such as Apache, Ngnix, IIS and the like. web server resolves a user request, know what you want to schedule the resource file, and then process the user request and the corresponding parameters of these files, and call database information, the final results will return to the browser client via the web server.

    6, returns the corresponding result to the browser

         HTTP response message is composed of three parts: status code, the response header and the response packet.

         Status code is a three-digit, the first digit defines categories of response, and there are 5 possible values:  

          · 1XX: indication information indicating that the request has been accepted, processing continues.

          · 2XX: success, indicating that the request has been successfully received, understood, accepted.

          · 3XX: Redirection, to fulfill the request must go a step further.

          · 4XX: client error, a syntax error or a request can not be achieved.

          · 5XX: server-side error, the server failed to achieve a legitimate request.

          Common status codes are: 200,204,301,302,304,400,401,404,500

    7, close the TCP connection

        To avoid the server and client both resource consumption and loss, both when there is no request or response transfer, either party may initiate a shutdown request.

    8, the browser parses rendering pages

        Upon receipt of your browser HTML, CSS, JS files, it needs to be rendered. 

        Browser is a side edge rendering resolution process. First, the browser parses the HTML file to build a DOM tree, and then parse CSS file to build the render tree, wait until after the render tree is built, the layout of the browser to start rendering tree and draw on the screen. This process is complex, involving two concepts: reflow (reflow) and repain (redraw). Each element of the DOM node is in the form of box model, which requires the browser to compute its location and size, this process is called reflow; when the position of the box model, size and other attributes, such as colors, fonts determined after down, the browser will start drawing content, this process is called repain. When the page is first loaded and bound to experience reflow repain. and repain reflow process is very consumption performance, especially on mobile devices, it destroys the user experience, sometimes resulting page Caton. So we should reduce reflow and repain as possible.

       JS parsing by the browser JS parsing engine completed.

       Browser resolution process, if you encounter a request external resources, such as images, JS and so on. The browser will download the resource process repeats 1-6. Request process is asynchronous, and will not affect the HTML document to load, but when the document is loaded encountered JS files, HTML documents hang rendering process, not only until the document is loaded JS file have to wait for parsing is finished, HTML rendering process will continue. The reason is because it is possible to modify the JS DOM structure, which means that before JS execution is complete, all subsequent downloads of resources is not necessary, which is the root cause JS blocked up resources to download. Load CSS file does not affect the load JS files, but it will affect the execution of the JS file. JS code is executed before the browser must ensure that the CSS file has been downloaded and loaded.

PS: two specific process steps are:

  • Browser cache: Browsers DNS record for some time, therefore, only the first place to resolve DNS requests;
  • Operating system cache: If you do not include this record in the browser cache, call the operating system will use the system to obtain records of the operating system (DNS guarantee the recent query cache);
  • Router cache: If the above two steps do not succeed DNS records, continue to search for the router cache;
  • ISP cache: If the above fails, continue to search ISP.

Guess you like

Origin www.cnblogs.com/fangdie/p/12598691.html