[Http] HTTP protocol learning Summary-first bullet: rfc2616 preliminary read Summary

Source: Internet
Author: User

Over the past few days, I have read rfc2616 and carefully studied the HTTP/1.1 protocol. I have always thought that if I want to develop the Internet, I must be familiar with the HTTP protocol, so I made up my mind to understand this agreement. In the past two days, I spent some time reading the RFC. I have a good understanding of the HTTP protocol and have a certain understanding of the fields and mechanisms, so calm down and make a good summary of the reading gains over the past two days. It is also a review and review.

The HTTP Protocol describes the communication protocol between the sender and the receiver, which is consciously observed by both parties. Of course, many browsers do not fully comply with this Protocol. HTTP is a protocol running on the application layer and operates based on the TCP protocol. Basically, it is the client/server Q & A mode, which also includes proxy, gateway, channel, and Cache during transmission.

What is hard to understand after reading the RFC is about the connection mechanism and cache mechanism. The other is basically the definition of the field and header format, which will not be listed one by one, provide a URL for quick query:Quick Reference to HTTP headers;

There are two important mechanisms: 

1. Connection Mechanism;

HTTP/1.1 supports two connection mechanisms: non-persistent connection and persistent connection. By default, persistent connections are used to reduce network latency and CPU consumption during connection establishment. Both the server and client assume that the connection is not closed, unless the header file sent by the other party contains "connection: Close", the connection will continue. Clients, servers, and proxies can end the connection at any time, and they should also have a mechanism to re-establish the connection and maintain correctness. Each client can only maintain two connections with one server. The proxy can only maintain 2n connections, and N is the number of active users of the proxy. During the connection, the user sends a message with "CT" to the server. If the connection is normal, the server returns a 100 (CONTINUE) message to the client, prompt that the client can continue sending.

HTTP also requires certain elements on the transport Road. It also specifies which fields can be changed by the opaque proxy, but cannot be changed.

II.Cache Mechanism;

Caching is mainly used in HTTP. In many cases, sending packets can be reduced, network I/O can be reduced, and the "Expiration" mechanism can be used for processing; the second is to reduce the operation of sending the entire package, reduce bandwidth requirements, and use the "Verification" mechanism for processing.

(1) Expiration model ),It is used on the server to create an expiration time. There are two calculation methods: priority order, age and expiration ). For the first type, the server will provide an age field (AGE) and a valid age (max-age), while the age calculation, the initial age when the server is generated plus the time from the server generation to the cache. If the field age exists, it indicates that the message is not first-hand and cached in the middle. To calculate whether a message expires, you need to use the following methods:

If (max_age_value)

Freshness_lifetime = max_age_value;

Else

Freshness_lifetime = expires_value-date_value;

Response_is_fresh = (freshness_lifetime> current_age );

The overall calculation method is intuitive and simple. to update the cache, you can add the following fields:

Cache-control: Max-age = 0; or cache-control: No-cache;

(2) Validation model ),When this mechanism is used, the cache first verifies to the server whether the current cache entry is the latest, and then receives a 304 prompt indicating not modified, the entry is the latest. Otherwise, a new cache entry is returned by the server. Two criteria can be used for verification. One is to use the server's"Last-modified", Use the condition get (if-modified-since or if-not-modified-since) to query. The second is to use the server to generate for each entry"Entity tag"The server determines how the tag is generated. Therefore, two authentication policies are derived. One is strong verification, that is, if the "entity tag" changes immediately after an entry changes, the second method uses weak verification, that is, if the entry changes, the "entity tag" remains unchanged, the verification conditions are weaker. However, the use of strong or weak verification depends on the server.

 

Next, we need to build a plug-in to steal food and try not to read the existing information on the Internet. We can analyze the HTTP Communication Process by ourselves ~~~

 

 

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.