←
🏠 Home Why HTTP versions matter? http/1 vs http/2 vs http/3
HTTP versions matters to frontend development because it drastically improves overhead of downloading assets/files & sending requests.
Http versions
Version | Year | Status |
---|---|---|
HTTP/1.1 | 1997 | Standard |
HTTP/2 | 2015 | Standard |
HTTP/3 | 2020 | Draft* |
* HTTP/3 is in draft because it’s waiting for final author review where 1 of the 3 author has approved.
Around 73% of users are using browsers that supports HTTP/3 protocol. (source)
HTTP/1.1
Key take-aways for HTTP/1.1:
- Opens several TCP connections for same server for parallel requests
- Text protocol: connection in text mode
- HTTP headers are not compressed
HTTP/2
Key take-aways for HTTP/2:
- Backward compatible with HTTP/1.1
- Multiplexed & concurrent
- single multiplexed TCP connection for same server; it means all requests are done with a single TCP connection
- Binary protocol: encodes request & response messages into binary
- connection in binary reduces transferred data
- Stream prioritization
- allow browser to indicate priorities of what to download first
- HPACK compression
- HTTP headers are compressed, hence better performance (ie. consider heavy cookies)
- Server push
- it means server can send resources to the client before client requests them
- Can be implemented without HTTPS
HTTP/3
Key take-aways for HTTP/3:
- backward compatible with HTTP/2
- based on QUIC as a transport layer (UDP)
- reduce latency & improve efficiency
- utilises UDP
- QPack compression
- redesign of HPack that reduces head-of-line blocking
- quicker handshake than HTTP/2
- must be implemented in secure & encrypted
Note:
- head-of-line blocking is where new request is blocked because first request is not completed yet
- using QUIC means even if there are packet loss, other requests are not stopped because of it
Summary
For each HTTP version, we have to use different strategies to improve performance.
HTTP/1.1 | HTTP/2 | HTTP/3 | |
---|---|---|---|
Communications protocol | TCP | TCP | QUIC (UDP) |
Header compression | - | HPACK | QPACK |
Message format | text | binary | binary |