HTTP/2: The Difference Between HTTP/1.1, Benefits and How to Use it

The Hypertext Transfer Protocol (HTTP) is a set of standards enabling Internet users to exchange information about Web sites. Since its introduction in 1991, the HTTP protocol has undergone four iterations. In this article, we will consider how this protocol works, and the difference between HTTP/1 and HTTP/2.

What is HTTP?

HTTP/1 is an upper-layer network protocol for transmitting data in the form of hypertext HTML documents and arbitrary data. With this protocol, the browser accepts data from servers and then displays it in a user-friendly form. The browser also sends user data to the server via HTTP.

For example, when a user navigates to a Cloud4U site, the web browser sends an HTTP request to the Cloud4U servers. As a result, the user gets the content of the site on the page. i.e. Cloud4U servers send HTTP responses, which the browser displays to the user.

How HTTP/2 was created?

HTTP/2 (HTTP/2.0) is the second version of the HTTP network protocol, based on the SPDY application layer protocol for accessing the web.

In the past, websites were simple and did not require much capacity. On modern web resources with high-quality images, JAVA scripts, CSS, flash animations, and other elements, just one page can weigh about 2 megabytes. With the introduction of new technologies, it became increasingly difficult for the protocol to handle pages with "heavy" content, which led to their slow loading.

Therefore, in 2015, a new version of HTTP/2 was announced. HTTP/2 is compatible with the previous version of the protocol and has some similarities. All the innovations related to solving problems regarding low performance and increasing speed are based on the previously released SPDY.

Differences between HTTP/2 and HTTP/1.1

HTTP/2 and HTTP/1.1

Multiplexing. In the previous version, one request required a separate TCP connection. And the more requests, the slower the browser worked. With multiplexing, the browser sends multiple requests through a single TCP connection.

Modern browsers use a limited number of TCP connections, which prevents them from loading "heavy" pages quickly. In contrast, http/2, which implements multiplexing technology, makes it possible to load a large amount of static content simultaneously, significantly improving performance.

Prioritization. Assigning a priority to any request based on weight or dependencies is a key performance differentiator in HTTP/2 vs HTTP1. The first type of prioritization implies that a thread receives a certain weight, which is further distributed between threads to make the load even. The second option involves the browser requesting the server to load some content elements separately, for example, first the JavaScript scripts, and then the images.

Header compression.If a website contains a lot of media content, the client sends a bunch of almost identical header frames, which increases latency and leads to excessive consumption of network resources. Without additional optimization of the combination of prioritized data streams, it is impossible to achieve the desired parallelism performance standards. 

HTTP/2 solves this by compressing a large number of redundant header frames. Compression is performed using the HPACK algorithm. The client and server store a list of headers used in previous requests.

HPACK compresses each header value before sending it to the server, which then looks up the encrypted information in the list of previously received values to recover the full header data. Compression with HPACK offers incredible performance benefits.

How to enable HTTP/2

If you do not know whether to change to the HTTP/2.0 protocol or not, look at the traffic logs of your site. Most users probably already use browsers that support the new protocol. Also, consider the specific features of your website. For example, for resources with large mobile traffic http/2 is a must. But do be sure to look at the browsers from which users are accessing your site, as many old browsers do not support the protocol.

To enable HTTP/2, there is no need to make any changes directly on the resource. The protocol is enabled on the hosting server. In the case of a virtual server or dedicated server, support for the protocol must be implemented at the module level to the Nginx or Apache server.

Was this helpful?
author: Jennifer
published: 07/01/2022
Latest articles
Scroll up!