A detailed description of the Web request process

Source: Internet
Author: User

Reprint to: http://www.nowamagic.net/librarys/veda/detail/1339

The HTTP communication mechanism is that during a complete HTTP communication , the following 7 steps will be completed between the Web browser and the Web server:

1. Establishing a TCP connection

Before HTTP work begins, the Web browser first establishes a connection to the Web server over the network, which is done through TCP, which works with the IP protocol to build the Internet, known as the TCP/IP protocol family, so the internet is also known as a TCP/IP network. HTTP is a higher level of application-level protocol than TCP, according to the rules, only the lower layer protocol is established before the protocol can be more connected, so the first to establish a TCP connection, the port number of the general TCP connection is 80.

2. Web browser sends request command to Web server

Once a TCP connection is established, the Web browser sends a request command to the Web server. For example: get/sample/hello.jsp http/1.1.

3. Web browser sends request header information

After the browser sends its request command, it also sends some other information to the Web server in the form of header information, and then the browser sends a blank line to notify the server that it has ended sending the header information.

4. Web server Answer

After the client makes a request to the server, the server responds back to the client, http/1.1, and the first part of the answer is the version number of the protocol and the response status code.

5. The Web server sends the answer header information

Just as the client sends information about itself along with the request, the server also sends the user with the answer about its own data and the requested document.

6. The Web server sends data to the browser

After the Web server sends the header information to the browser, it sends a blank line to indicate that the header information is sent to the end, and then it sends the actual data requested by the user in the format described in the Content-type reply header information.

7. The Web server shuts down the TCP connection

In general, once the Web server sends the request data to the browser, it closes the TCP connection and then if the browser or server joins this line of code in its header information:

Connection:keep-alive

The TCP connection remains open after it is sent, so the browser can continue to send requests through the same connection. Maintaining a connection saves the time it takes to establish a new connection for each request and also saves network bandwidth.

The following reprint to: http://www.cnblogs.com/SanMaoSpace/archive/2013/06/12/3132489.html

The client parsing HTML steps are as follows:

<1> parse HTML structure;
<2> load external scripts and style sheet files;
<3> parse and execute script code;
<4> Constructs an HTML DOM model;
<5>. Loading external files such as pictures.

The difference between onload and ready:
The difference between the onload and ready is to be noted here:
One is ready, indicating that the DOM document tree has been loaded parsing and parsing completed (not including pictures and other non-text media files);
The second is onload, which refers to all the resources on the page (all elements including images, etc.) are loaded.

Say ready is faster than onload the most significant is that a page has a large picture, loading for a long time, onload only after the picture is loaded, and ready does not have to wait for the picture to be loaded.
This difference is consistent with the Window.onload and $ (document). Ready ().

A detailed description of the Web request process

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.