Home >Common Problem >The difference between http2.0 and http1.1
What is HTTP 2.0?
HTTP/2 (Hypertext Transfer Protocol version 2, originally named HTTP 2.0), is the second major version of the HTTP protocol. Used on the World Wide Web. HTTP/2 is the first update of the HTTP protocol since the release of HTTP 1.1 in 1999. It is mainly based on the SPDY protocol (a TCP-based application layer protocol developed by Google to minimize network delays, increase network speed, and optimize users' network usage. experience).
Compared with HTTP 1.1, the main differences include:
HTTP/2 uses a binary format instead of a text format
HTTP/2 is fully multiplexed, not ordered and blocking - only one connection is needed for parallelism
Using header compression, HTTP/2 reduces overhead
HTTP/2 allows the server to actively "push" responses to the client cache
Recommended course: PHP Tutorial.
Why is HTTP/2 binary?
Compared to text protocols like HTTP/1.x, binary protocols are more efficient to parse, more compact "online", and more importantly, have fewer errors.
Why does HTTP/2 require multiplexing?
HTTP/1.x has a problem called head-of-line blocking , it means that it is more efficient for a connection to submit only one request at a time. If there are more requests, it will become slower. HTTP/1.1 tried to use pipelining to solve this problem, but the effect was not ideal (large data volume or slow response will hinder the requests behind it). In addition, due to the network media (intermediary) And the server cannot support the pipeline well, making deployment difficult. Multiplexing can solve these problems very well, because it can handle multiple message requests and responses at the same time; it can even mix one message with another during the transmission process. So the client only needs one connection to load a page.
Why do message headers need to be compressed?
Assume that a page has 80 resources to load (this number is quite conservative for today’s Web) , and each request has a 1400-byte message header (which is also not uncommon due to the existence of cookies and references), and it takes at least 7 to 8 back and forth "online" to obtain these message headers. That doesn't include response time - that's just the time it takes to get them back from the client. This is all due to TCP's slow-start mechanism, which determines which packets to fetch back and forth based on how many known packets there are - which obviously limits the number of packets that can be sent in the first few round-trips. In contrast, even slight compression of the headers can allow those requests to be processed in just one round trip - sometimes even one packet. This overhead can be saved, especially when you consider mobile client applications, which even under good conditions typically see round-trip latencies of several hundred milliseconds.
What are the benefits of server push?
When the browser requests a web page, the server will send back HTML. Before the server starts sending JavaScript, images, and CSS, the server needs to wait for the browser to parse the HTML and send all inline Resource requests. The server push service avoids round-trip delays by "pushing" content it thinks the client will need into the client's cache.
The above is the detailed content of The difference between http2.0 and http1.1. For more information, please follow other related articles on the PHP Chinese website!