As the WWW transmission protocol, HTTP is very simple: the client establishes a connection with the remote server, then sends a request, the server processes the request, returns response, and closes the connection.
However, this simple process has some problems:
First look at the request:
GET/index.html HTTP/1.0/* indicates that the action is get and/index.html */
Accept: text/plain/* here there can be n more headers, which are described in rfc822 */
Accept: text/html
Accept :*/*
User-Agent: OnlyVC-1.0/* client implementation name */Server gives response: HTTP/1.0 200 OK
Server: MDMA/0.1
Mime-type: 1.0
Content-Type: text/html
Last-modified: Tue Mar 11 00:25:33 2008
Content-Length: 2003
/* Note that there must be a blank line here! */
<Title> onlyvc.cn </title>
<H1> welcome to onlyvc.cn
OK. So far, all web users will know.
Next, we can use tools such as tcpdump to look at http. We will not paste data here, so we can divide a process into six stages, in this process, you need to pay attention to an important metric: round trip time (RTT). This value refers to the time that a packet sends from one end to the other end and then returns it. However, TCP has a very strange problem. Simply put, when a connection is established, it starts to test the speed of a few small packages before transmitting data. This process is called slow start.
Http1.1 does not need to wait for a packet to be sent before being confirmed (acknowledged) and then send the next packet. We can send a packet, regardless of the packet, and then send the next packet.
The Design of 2 connection per hostname in RFC was reasonable at that time, but it is far from enough for Internet applications. However, as a website developer, it is necessary to distribute resources on a page to multiple hostnames, but the number of hostnames should be 2 ~ Four are recommended. If a large number of resources need to be referenced on the page, especially for a collection-type website with many products, the cookie size is considerable. If all our content comes from one domain, assume that one page has 30 images and the cookie size is 20 KB, that is, 30*20 = KB of data has been transmitted useless, distribution after other hostnames is a good way to reduce cookie-taking because cookies are scoped.