What happens when you enter a URL in a browser

Source: Internet
Author: User
Tags ack mime file domain name server browser cache domain server

After entering a URL in a browser, the browser undergoes the following 5 steps:

1. Parsing URLs

2.DNS Domain Name resolution

3. The browser establishes a TCP link with the website (three handshake)

4. Request and Transfer data

5. Browser Rendering page

First, resolve the URL

What is a URL:

URL (Universal Resource Locator) The same resource locator, commonly known as a web address or URL, used to represent the address of a page resource

The URL consists mainly of a few parts:
1. Transmission protocol

2. Server

3. Domain Name

4. Port

5. Virtual Directory

6. File name

7. Parameters

8. Anchor

In other words, the usual URL is this.

It's like that, Http://www.baidu.com:8021/pages/index.html?id=3&page=1#/name.

The sites we see are deployed to the line, and generally do not display the port number, '? ' To ' # ' shows parameters, multiple parameters separated by &, ' #后面显示的是锚 '.

When the URL is entered in the browser, the browser first identifies the URL that was received and extracts the Domain name field

Second, DNS domain name resolution

DNS domain name resolution is actually a database of domain names and IP

IP address We are generally difficult to remember, but the machine can recognize each other IP address, so people invented the domain name, so that the domain name and IP address one by one correspondence between them, and the resolution between them is called Domain name resolution, the domain name resolution needs to be done by a dedicated domain name resolution server, the process is automatic.

In the browser can enter the IP address to browse the site, you can also enter the domain name to browse the site, although the content is the same, but the process is not the same, the input IP address is directly from the host call address, and input domain name is through the domain name resolver to the corresponding IP address, and then from the host to invoke the content.

There are several steps you can take in DNS domain name resolution:

Query the browser cache (The browser caches the DNS 2-30 minutes before getting the time) if not found

Check the system cache Check the Hosts file This file holds the domain name and IP data of the Web site previously questioned, it is like a local database, if found can directly obtain the IP address of the destination address, no need to

Check that the router cache router is cached by its own DNS, which may include the contents of this query, and if not, it will

querying the IPs DNS cache IPS service provider DNS cache (local server cache) may have relevant content here, if there is no need to

recursive queries from the root domain server to the top-level domain name server to the domain name server, then search for the IP address

HTTP access server

The IP address of the domain name can be obtained by the above lookup, then the TCP link is initiated to the HPP server located

Third, the browser and the Web site for TCP connection (three-time handshake)

First handshake: The client sends a request to the server (SYN = 1) Waiting for the server to confirm;

Second handshake: The server receives the request and confirms that it responds to an instruction (SYN = 1, ACK = 1);

Third handshake: The client receives a reply instruction from the server and returns an acknowledgment (ACK = 1).

This three-time handshake establishes a connection between the client and the server and can now send the request and transmit the data.

Iv. request and transfer of data

For example, through a GET request to access "http://www.cnblogs.com/", through the browser's networ can see:

Requested URL (' URL '): https://www.cnblogs.com/

Request Method: GET

Remote Address: 42.121.252.58:443

Status code: $ OK

Request header ....

Response header .....

The request header contains a cookie information, if the cookie is the first access, the server will be prompted to establish user cache information, if there is a cookie, you can use the corresponding key value of cookies, to find the corresponding cache, the cache is stored in the user name, password, and some user settings.

With this get request, and the server's response, the destination file on the server can be transferred to the browser for rendering.

Five, browser rendering page

The client takes the file back from the server, finds the HTML and MIME files, and, through the MIME file, the browser knows to use the page rendering engine to process the HTML file.

1. The browser will parse the HTML far, then create a DOM tree.

In DOM trees, each HTML tag has a node, and each text has a corresponding text node.

2. The browser parses the CSS code, calculates the final style data, and forms the CSS object model Cssom

The unreasonable CSS code is first ignored and then rendered in the style order of the browser by default--user settings---inline style--in HTML.

3. Building a rendering tree with Dom and cssdom (rendering trees)

The render tree and the DOM tree are a bit similar, but there's a difference.

The DOM tree is exactly the same as the HTML tag one by one, but the render tree ignores elements that do not need to be noisy, such as head,display:none elements, and each row in a large piece of text corresponds to a node in the render tree, and each node in the render tree stores the corresponding CSS property

4. The browser draws the page directly to the screen based on the render tree

What happens when you enter a URL in a browser

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.