Junior
Tell us about the versions of HTTP and their differences.
sobes.tech AI
Answer from AI
Main versions of HTTP:
- HTTP/0.9: Basic version for transmitting simple HTML documents. Supported only the
GETmethod, lacked headers and response statuses. - HTTP/1.0: Introduced support for headers (Content-Type, User-Agent), methods
POSTandHEAD, response statuses. Connection was closed after each request/response. - HTTP/1.1: Significant improvements:
- Persistent connections - reuse TCP connection for multiple requests.
- Pipelining - sending multiple requests without waiting for the previous response (though poorly implemented and rarely used).
- Virtual hosts (Host header).
- Partial GET requests (Range header).
- Caching (Cache-Control, ETag, Last-Modified).
- Methods PUT and DELETE.
- HTTP/2: Protocol based on Google's SPDY. Main differences:
- Binary protocol instead of text - more efficient parsing.
- Multiplexing - parallel transmission of multiple requests/responses over one TCP connection. Eliminates the "head-of-line blocking" problem of HTTP/1.1 pipelining.
- Header compression (HPACK) - reduces data size.
- Prioritization (Server Push) - server can send resources likely needed by the client before it requests them.
- HTTP/3: Based on UDP protocol (using QUIC - Quick UDP Internet Connections) instead of TCP. Aimed at improving performance, especially in unstable networks:
- Eliminates "head-of-line blocking" at the TCP connection level. If one packet is lost in TCP, all subsequent packets are blocked until retransmission. In QUIC (and HTTP/3), only the stream to which the lost packet belongs is blocked.
- Faster connection establishment (0-RTT or 1-RTT).
- QUIC includes its own flow control and reliability mechanisms.
Main differences in the table:
| Feature | HTTP/1.0 | HTTP/1.1 | HTTP/2 | HTTP/3 |
|---|---|---|---|---|
| Protocol | TCP | TCP | TCP | UDP (QUIC) |
| Format | Text | Text | Binary | Binary |
| Default connection | Short-lived | Persistent | Persistent (multiplexing) | Persistent (QUIC Streams) |
| Multiplexing | No | Pipelining (imitation) | Yes | Yes |
| Header compression | No | No | HPACK | QPACK (in QUIC) |
| Server Push | No | No | Yes | Yes |
| HOL Blocking (TCP) | Yes (at request level) | Yes (at request level) | Yes (at connection level) | No (at stream level) |
Example of an HTTP/1.1 request:
GET /index.html HTTP/1.1
Host: www.example.com
User-Agent: curl/7.64.1
Accept: */*
Conceptual example of an HTTP/2 request (binary):
// Request 1: Get /index.html
// :method = GET
// :path = /index.html
// :authority = www.example.com
// Request 2: Get /style.css
// :method = GET
// :path = /style.css
// :authority = www.example.com
// ...transmitted in parallel over one connection