What is HTTP/2, and How Can it Benefit Your Website?

minute/s reading time

For the last 20 years, most servers have used the HTTP/1.1 protocol. However, HTTP/2 made its debut in November 2020. The difference between HTTP/1.1 and HTTP/2 is that the latter can send multiple simultaneous requests to servers in one connection.

HTTP/2 replaces HTTP/1.1 but doesn’t replace the protocol; the Application Programming Interfaces (API) are maintained, as are HTTP/1.1 methods and status codes. Benefits of HTTP/2 include improved website performance, data compression of headers, and speculative pushing of data.

HTTP/2, also known as 'h2’, enables multiple requests for different file types; these include files such as jpeg, js, HTML, etc. HTTP/2 is a significant Web technological advancement that decreases server requests and enables more efficient Web crawling.

What is HTTP/2?


(Source: CooliceHost)

HTTP Hypertext Transfer Protocol (HTTP) is the exchange of information between client and server. The HTTP protocol for the World Wide Web, developed by Timothy Berners-Lee, has been standard since 1989. With HTTP, a client will send a text request to the server by 'GET' or 'POST.'A client sends a text request to a server; achieved by calling 'GET' or 'POST'; in return, the server sends a resource back to the client. The requests and responses go back and forth between the client and server.

The exchange of information will occur until the web browser has received the required information to display the content on the client’s screen. The single application layer exchange between client and server uses Transmission Control Protocol (TCP) and Internet Protocol (IP) to communicate.

When using HTTP/2, there is a dramatic reduction in the cost of using HTTP because only one connection is open per domain. It uses one connection in parallel and out of order. HTTP/2 is binary rather than textual. It is multiplexed and can send multiple information signals in a single link.

HTTP/2 has a binary option rather than using text. The advantage of the binary format is that requests and responses are condensed into smaller packets, making information transfer more flexible. In addition, instructions are converted into binary form and sent over the network.

Problems with HTTP/1


(Source: CooliceHost)

The problems associated with HTTP/1 or h1 relate to the fact that web pages have more bytes and objects and are more complex these days. Issues of performance and usability have now resulted from the older technology. The problems relate to 'pipelining,' inefficient use of TCP/IP, and duplication of header data.

The h1 protocol allows pipelining, allowing browsers to request a web page with any CSS or Javascript needed to display the page. However, head-of-line blocking occurs when responses arrive in a singular form in the order sent.

A common workaround for the problem is having more than one TCP connection to the server. Hence most browsers today allow six links to the same domain. TCP is reliable over poor network connections using a ‘congestion window.' The TCP sends one extra packet for every acknowledged one until reaching maximum bandwidth.

On maximum bandwidth is attained, the TCP connection repeats. The connection progresses slowly at first but will eventually operate at peak performance. The problem is made worse by many web pages needing over 100 HTTP requests to display a whole page. With the h1 protocol, the HTTP headers, including cookies, include requests with duplicated data. A common way of working around this duplication is to use images from a no-cookie domain. However, this approach can increase complexity and functionality.

Why is HTTP/2 multiplexed?


Multiplexing occurs when a single TCP connection handles multiple HTTP requests and responses. The reduction of memory usage, as well as processing speed, occurs with the use of a single session, which reduces operational costs. A new session will start with a broken connection.

Multiplexing ensures that no message must wait for another one to finish first.   Therefore, clients and servers can send concurrent requests and responses, which means more efficiency. In addition, multiplexing allows the construction of multiple streams in parallel and using a single TCP connection.

Knowing when to use multiplexing will depend on the situation at hand. For example, if a single connection at maximum bandwidth is possible, then HTTP/2 multiplexing works well. However, performing HTTP requests over multiple connections makes more sense if it cannot use maximum bandwidth.

Server Push Benefits


A feature of HTTP/2 is Server Push, which allows the server to send additional responses before the client has requested them. It is an intelligent guess by the server as to what the client may need. The guesswork by a server can reduce the time required for retrieving a resource.

Latency increases with the Push capability, and Web traffic reduces this way. Latency means the delay between a client's action and a web application's response to that action. A drawback to Push is that the client may already have the item in the cache.

Why HPACK Header Compression?


CRIME or Compression Ratio Info-leak Made Easy, is a way of taking advantage of web cookies used during data compression. Unfortunately, CRIME allows attackers to hijack an authenticated web session, a client-side attack. Still, the server can protect the client by declining the feature combinations.

HPACK is a header compression algorithm that HTTP/2 supports. HPACK can withstand CRIME attacks, this is because it uses string matches in a way that forces attackers to guess headers in their entirety.  HPACK doesn’t use the DEFLATE option, this was particularly vulnerable to CRIME.

Instead, HPACK uses static and dynamic dictionary compression as well as Huffman encoding. Headers can be compressed by about 30% using HPACK. The three main benefits of HPACK are its resilience against CRIME and its encoding of large headers. In addition, HPACK can encode frequently used headers as a variable-length integer. Huffman encoding assigns binary codes to characters used frequently. As a result, the header can access these characters in smaller packets, and fewer bits are needed to complete the transmission as they are compressed.

As a result, web performance will improve with the transferral of a smaller quantity of data. HPACK also uses indexing, using the index from the table instead of the literal string. As a result, responses are smaller and faster, which reduces ingress (download speed) and egress (upload speed) bandwidth.

Final Thoughts


HTTP is how information on the World Wide Web moves between clients and servers. HTTP/2 is the latest improvement in the HTTP protocol. The benefits of this technology include, amongst other things, header compression, decreased web traffic, as well as the ability to use a single TCP connection, leading to a more efficient flow of information over the internet.

About the Author

I have been in the 'online business' space since 2009 when I started an eCommerce business selling motorcycle parts (sold in 2012). Since then I have owned and operated several successful online business (and had a fair share of failures), along with owning offline home services businesses. Currently my focus is online businesses that are profitable with paid traffic. As a 'self employed individual' I do not use Linkedin, but you can connect with my on my personal instagram and youtube which largely revolve around my mountain biking passion!