HTTP/2: the difference between HTTP/1.1, benefits and how to use it

Details on how to setup HTTP/2 for ubuntu and Server Push usage are also available on Factory Github.

What is HTTP?

If you are new to this theme, continue to read this block, but if you’re familiar with this, skip this paragraph and go straight forward to the next one.

What is HTTP/2?

In 2015, Internet Engineering Task Force (IETF) release HTTP/2, the second major version of the most useful internet protocol, HTTP. It was derived from the earlier experimental SPDY protocol.

  • High-level compatibility with HTTP/1.1 — methods, status codes, URIs and header fields.
  • Page load speed improvements trough:
  • Compression of request headers
  • Binary protocol
  • HTTP/2 Server Push
  • Request multiplexing over a single TCP connection
  • Request pipelining
  • HOL blocking (Head-of-line) — Package blocking

Request multiplexing

HTTP/2 can send multiple requests for data in parallel over a single TCP connection. This is the most advanced feature of the HTTP/2 protocol because it allows you to download web files asynchronously from one server. Most modern browsers limit TCP connections to one server.

Header compression

HTTP/2 compress a large number of redundant header frames. It uses the HPACK specification as a simple and secure approach to header compression. Both client and server maintain a list of headers used in previous client-server requests.

Binary protocol

The latest HTTP version has evolved significantly in terms of capabilities and attributes such as transforming from a text protocol to a binary protocol. HTTP1.x used to process text commands to complete request-response cycles. HTTP/2 will use binary commands (in 1s and 0s) to execute the same tasks. This attribute eases complications with framing and simplifies implementation of commands that were confusingly intermixed due to commands containing text and optional spaces.

Benefits:

  • Low overhead in parsing data — a critical value proposition in HTTP/2 vs HTTP1.
  • Less prone to errors.
  • Lighter network footprint.
  • Effective network resource utilization.
  • Eliminating security concerns associated with the textual nature of HTTP1.x such as response splitting attacks.
  • Enables other capabilities of the HTTP/2 including compression, multiplexing, prioritization, flow control and effective handling of TLS.
  • Compact representation of commands for easier processing and implementation.
  • Efficient and robust in terms of processing of data between client and server.
  • Reduced network latency and improved throughput.

HTTP/2 Server Push

This capability allows the server to send additional cacheable information to the client that isn’t requested but is anticipated in future requests. For example, if the client requests for the resource X and it is understood that the resource Y is referenced with the requested file, the server can choose to push Y along with X instead of waiting for an appropriate client request.

Benefits:

  • The client saves pushed resources in the cache.
  • The client can reuse these cached resources across different pages.
  • The server can multiplex pushed resources along with originally requested information within the same TCP connection.
  • The server can prioritize pushed resources — a key performance differentiator in HTTP/2 vs HTTP1.
  • The client can decline pushed resources to maintain an effective repository of cached resources or disable Server Push entirely.
  • The client can also limit the number of pushed streams multiplexed concurrently.

For HTTP/1.1:

For HTTP/2:

HTTP/2 server push:

Browser Compatibility

Use HTTP/2 and speed up your site

HTTP/2 provides us with many new mechanics that will mitigate HTTP/1.1 issues and ones that will boost your web page performance. Currently, it is widely supported by web clients so its implementation is painless. Although implementation of HTTP/2 protocol is easy you should have in mind that with it you will probably have to change the mechanics (like serving assets to the client) to use the full potential of this protocol.

We design and develop native mobile & web applications for startups and successful companies.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store