What happens when the URL is entered in the browser address bar to display the page?

URL parsing : The browser will parse the URL you enter and decompose it into different components, including protocol (such as HTTP or HTTPS), host name, path, etc.

DNS resolution : The browser needs to resolve the host name to the corresponding IP address. It sends a request to a DNS (Domain Name System) server for the IP address corresponding to the hostname.

Establish a network connection : The browser uses the IP address obtained through analysis to establish a network connection with the server. For the HTTP protocol, port number 80 is used by default, and for the HTTPS protocol, port number 443 is used by default.

Send HTTP request : Once a network connection is established, the browser sends an HTTP request. This request contains your URL and other relevant information, such as the request method (GET, POST, etc.), request headers (including browser information, required content type, etc.), and request body (for POST requests).

Server processing request : After the server receives the request sent by the browser, it will process it. Depending on the configuration and application on the server, this may include looking up the requested resource, executing backend logic, fetching data from a database, etc.

Response return : After the server processes the request, it generates an HTTP response. The response contains the HTTP status code (a numeric code indicating whether the request was successful or not) and the response content. Common status codes include 200 (success), 404 (not found), and 500 (server error).

Receiving the response : After the browser receives the HTTP response returned by the server, it will perform corresponding processing according to the content type in the response. For example, if the response is HTML content, the browser will parse it and render it into a web page.

Rendering the page : The browser parses and renders the page based on the received resources such as HTML, CSS, and JavaScript, as well as the browser's own rendering engine. It will build the DOM tree (Document Object Model), CSSOM tree (CSS Object Model) and rendering tree, and finally display the page to the user.

Downloading resources : During page rendering, the browser also downloads other resources referenced in the page, such as images, style sheets, script files, etc. These resources will be cached by the browser for faster loading on subsequent visits.

Page completion : When all resources of the page have been downloaded, parsed, and rendered, the page is displayed and can be interacted with by the user.

Guess you like

Origin blog.csdn.net/qq_44063746/article/details/130688496