Google started development on what would become the basis of HTTP/2 as early as 2010. Known as SPDY, it was designed to work alongside the then-current HTTP/1.1 protocol by manipulating and optimizing traffic as it left the server. In 2015, SPDY was integrated into – and gradually replaced by – HTTP/2.
Like SPDY, HTTP/2 was designed to overcome many of the shortcomings of HTTP/1.1, particularly with how content is delivered over a network. Users see improvements in page load speed and responsiveness, while website administrators see lower resource usage. The result is a faster experience with no change to the existing functionality of the web.
How HTTP/2 Works
HTTP/2 focuses on optimizing the flow of content between clients and servers. It’s fully backwards-compatible with HTTP/1.1, meaning websites will work the same with either protocol.
When a user connects to a server, their browser negotiates an HTTP session with the server. The type of session created will vary depending on the features supported by the browser and the server. If both parties support HTTP/2, the server uses the HTTP/2 protocol to shape and optimize traffic before it passes through the network to the user.
Once the browser and server agree to use HTTP/2, they can utilize features such as compression, multiplexing, and server push to optimize the connection. If either party doesn’t support HTTP/2, both the browser and server fall back to HTTP/1.1.
Differences Between HTTP/2 and HTTP/1.1
In order to maintain backwards-compatibility with HTTP/1.1, HTTP/2 maintains much of the functionality of HTTP/1.1. However, it does introduce some drastic changes including:
- Simultaneous connections, or multiplexing: HTTP/1.1 can only fetch one resource at a time, whereas HTTP/2 can fetch multiple resources over a single connection simultaneously. (An example of this is shown in the visual at the top of this page.)
- Header optimization: Each and every request over HTTP contains header information. With HTTP/1.1, many of these headers are repeated over a single session. HTTP/2 removes redundant headers while compressing the remaining headers.
- Binary format: HTTP/1.1 sends data in a textual format, whereas HTTP/2 sends data in a binary format. While binary is more difficult to visually read, it reduces the amount of errors and inefficiencies present in textual formats.
- Server Push: With HTTP/1.1, servers have to wait for the client to initiate a connection. With HTTP/2, servers can push resources to the client proactively.
HTTP/2 also solves many of HTTP/1.1’s workarounds such as:
- Domain sharding which uses multiplexing by spreading resources onto different domains
- Concatenation and sprite sheets where multiple resources are combined into a single larger resource to encourage multiplexing
- Inlining assets where assets are bundled directly in the HTML document to avoid downloading multiple resources
Although HTTP/2 is still fairly new, support for it continues to grow. Most major browsers support HTTP/2 including Microsoft Edge, Firefox, Chrome, Safari, and Chrome for Android. Many popular web servers include native support for HTTP/2 including the Apache HTTP Server, NGINX, and Tomcat. As software support for HTTP/2 increases, so will adoption across websites and web platforms.