What are the Differences Between HTTP/1.0 and HTTP/2.0?
Key Points
This analysis focuses on the differences between the two protocols from the perspectives of connection methods, data transmission formats, and header compression.
Connection Methods
- HTTP/1.0
- Short Connections: Each request requires a separate TCP connection, which is closed immediately after the request is completed.
- Head-of-Line Blocking: In the same connection, subsequent requests are blocked until the previous request is completed.
- HTTP/2.0
- Persistent Connections: Connections are reused by default, reducing the latency of TCP handshakes and slow starts.
- Multiplexing: A single TCP connection can handle multiple requests and responses concurrently, avoiding head-of-line blocking.
Data Transmission Formats
- HTTP/1.0
- Text Format: Requests and responses are transmitted in plain text (e.g.,
<span><span>GET /index.html HTTP/1.0</span></span>
), which has low parsing efficiency and is prone to errors. - HTTP/2.0
- Binary Framing: Data is divided into smaller binary frames (e.g., HEADERS frames, DATA frames), allowing for efficient transmission with a low error rate.
- Streams: Each request/response is assigned a unique stream ID, supporting priority and dependency control.
Header Compression
- HTTP/1.0 (No Compression): Each request must resend the complete header (e.g., Cookie, User-Agent), wasting bandwidth.
- HTTP/2.0 (HPACK Compression Algorithm): Headers are compressed using static and dynamic tables, reducing redundant data (typical compression rates can reach 50%-90%).
Server Push
- HTTP/1.0 (No Push Function): The client must actively request each resource (e.g., CSS, JS).
- HTTP/2.0 (Active Push Function): The server can predict client needs and proactively push related resources (e.g., automatically pushing CSS when HTML is requested), reducing round-trip latency.
Summary
Feature | HTTP 1.0 | HTTP 2.0 |
---|---|---|
Connection Management | Short Connections | Single Connection Multiplexing |
Data Transmission | Text Format | Binary Framing |
Header Processing | No Compression | HPACK Compression |
Head-of-Line Blocking | Exists (Application Layer) | None (Application Layer) |
Typical Latency | High (Multiple Handshakes) | Low (Multiplexing) |
Main Application Scenarios | Static Web Pages | High-Concurrency Web Applications |
Extended Knowledge
Evolution of HTTP Versions
Comparison of Header Compression: QPACK vs HPACK
- HPACK: This is the mechanism used for header compression in HTTP/2.0, relying on the ordered delivery of packets. HPACK manages header fields using static tables and dynamic tables to reduce the amount of duplicate data transmitted.
- QPACK: This is the header compression algorithm designed for QUIC in HTTP/3.0, addressing the limitations of HPACK in unordered streams. QPACK employs Huffman coding and lookup table mechanisms, while introducing the concepts of static and dynamic tables for efficient management of header field compression and decoding.