In the address bar, enter a URL, press Enter to this page revealed, what will occur between?

This is a high-frequency interview questions

Router cache, cache not then find whether there is record hosts file system, if not then query the DNS server to obtain the IP address of the server, the browser based on the IP and the corresponding port number, construct an HTTP request, the request report this request will include the text information, mainly request method, and request data requesting accompanying description, and the HTTP request encapsulated in a TCP packet, the TCP packet will sequentially passes through the transport layer, network layer, data link layer , the physical layer to the server, the server parses the request to respond to return the appropriate HTML browser as HTML is a tree, tree browser constructed in accordance with the HTML DOM, if encountered in the process of constructing the DOM tree JS JS scripts and external links, it will stop building the DOM tree to perform and download the appropriate code, which can cause obstruction, which is why it is recommended JS code should be placed behind the HTML code, then the external style, internal style, inline style build a CSS object model tree CSSOM tree, and after the completion of construction of the DOM tree together To render the tree, where the main job is to exclude non-visual node, such as script, meta tags and exclude display nodes none, and after layout, layout largely determine the location and size of each element, after rendering the page as an HTML file will contain pictures, video, audio and other resources, in the process of parsing the DOM, the encounter which will be downloaded in parallel, the browser has some limitations on the number of concurrent downloads per domain, typically 4-6, of course, All of these requests, we also need to focus on is the cache, the cache usually by cache-control, Last-Modify, Expires header fields and other controls. Difference Cache-Control and Expires is that the Cache-Control using relative time, Expires used is based on the absolute time on the server side, because of jet lag, generally use Cache-Control, when requesting these have set cache data will first see has expired, if not directly use the local cache expired, expired and whether the request to modify files on the server check if the response time is set ETag value as at the time of the request

Simplify what is:
  1. Check the cache
  2. DNS resolution
  3. TCP connection
  4. Send an HTTP request
  5. HTTP server processes the request and returns the packets
  6. Browser parses rendering pages
  7. Connection is ended

Guess you like

Origin www.cnblogs.com/hukuangjie/p/11374575.html