Exploring HTTP/2 and HTTP/3

By Michele Berardi
Picture of the author
Published on
image alt attribute

Exploring HTTP/2 and HTTP/3

Delve into the workings of HTTP across its versions for a deeper understanding.

In the early 1990s, the World Wide Web's foundation was laid down by Tim Berners-Lee and his team at CERN. They introduced four key components:

  • HTML: A format for creating web pages
  • HTTP: A protocol for sending data
  • The first web browser, WorldWideWeb, for viewing pages
  • An early web server (httpd) for data delivery

HTTP operates atop TCP/IP, residing within the application layer, as illustrated in the OSI model diagram.

HTTP/0.9: The Original

The pioneering version of HTTP was simplistic: it supported only GET requests, lacked headers and status codes, and exclusively used HTML. Like in HTTP/1.0 and 1.1, it employed ASCII text for its message format.

Request:
GET /mypage.html

Response:
<html>
  A very simple HTML page
</html>

HTTP/1.0: Structuring HTTP

HTTP/1.0 introduced a structured format resembling a memo, new methods (HEAD, POST), MIME types, status codes, and versioning.

Request:
GET /mypage.html HTTP/1.0
User-Agent: NCSA_Mosaic/2.0 (Windows 3.1)

Response:
200 OK
Date: Tue, 15 Nov 1994 08:12:31 GMT
Server: CERN/3.0 libwww/2.17
Content-Type: text/html

<HTML>
A page with an image
  <IMG SRC="/myimage.gif">
</HTML>

HTTP/1.1: Enhancements for Efficiency

Introduced in early 1997, HTTP/1.1 added persistent TCP connections, the Host header for supporting multiple domains per IP, and standardized headers for encoding, caching, language, and MIME types.

Request:
GET /api/fruit/orange HTTP/1.1
Host: www.fruityvice.com
Accept-Encoding: gzip, deflate, br

Response:
HTTP/1.1 200 OK
Server: nginx/1.16.1
Date: Sun, 10 Mar 2024 20:44:25 GMT
...
Content-Type: application/json

{"name":"Orange", "id":2, ...}

HTTP/2: Multiplexing and Efficiency

HTTP/2, proposed in 2015 and inspired by Google's SPDY, introduced multiplexing, binary formatting, and HPACK header compression. It addressed the head-of-line blocking issue in HTTP/1.x by allowing multiple messages to share a TCP connection without waiting for the previous message to finish.

In HTTP/2, streams allow multiple requests and responses to interleave on a single connection, overcoming HTTP/1.x limitations.

HTTP/3: QUIC as a Game-Changer

Emerging from QUIC (a transport protocol by Google), HTTP/3 uses UDP to reduce connection establishment times, improve resilience to packet loss, and eliminate head-of-line blocking present in TCP and TLS. Each QUIC packet is independently encrypted, allowing out-of-order delivery without affecting unrelated streams.

HTTP/3 utilizes QUIC, enabling faster connection times, resilience to packet loss, and independent stream management.

Comparing HTTP/1.1, HTTP/2, and HTTP/3

The evolution from HTTP/1.1 to HTTP/3 involves changes in transport protocols, handling of head-of-line blocking, message formatting, header compression, and more. While HTTP/2 and HTTP/3 are the preferred versions, HTTP/3 excels in unstable connections like mobile and satellite networks due to its design. However, on stable connections, HTTP/2 often outperforms HTTP/3.

Conclusion

Choosing between HTTP/2 and HTTP/3 depends on the network stability and specific use case. It's advisable to conduct compatibility and performance tests. Additionally, servers can support both protocols, leaving the choice to the client.

This nuanced understanding highlights the technological advancements and optimizations in the HTTP protocol, shaping the efficiency and reliability of web communication.

Stay Tuned

Want to become a AI pro?
The best articles, links and news related to AI delivered once a week to your inbox.