HTTP/2 — All you need to know. HTTP/2 originally incepted as Google’s…
By: Vivek Shivhare
Tags: Java, Https, Computer Science, Web Development, Distributed Systems

HTTP/2 — Everything you need to know about HTTP/2

HTTP/2 originally incepted as Google’s SPDY(pronounced “speedy”) protocol, which was designed to solve performance problems inherent in HTTP/1.1.HTTP/2 is the first upgrade to the Hypertext Transfer Protocol since 1999.It improve website performance by optimizing how HTTP is expressed “on-the-wire.” It doesn’t change the semantics of HTTP, which means header fields, status codes, and cookies work exactly the same way as in HTTP/1.1.

What Was Wrong ?

HTTP1.1 was limited to processing only one outstanding request per TCP connection, forcing browsers to use multiple TCP connections to process multiple requests simultaneously. However, using too many TCP connections in parallel leads to TCP congestion that causes unfair monopolization of network resources.

Web browsers using multiple connections to process additional requests occupy a greater share of the available network resources, hence downgrading network performance for other users.

Issuing multiple requests from the browser also causes data duplication on data transmission wires, which in turn requires additional protocols to extract the desired information free of errors at the end-nodes.

Before HTTP/2 industry dealt these constraints with solution practices such as domain sharding, concatenation, data inlining and spriting, among others.

Web has evolved well beyond the capacity of legacy HTTP-based networking technologies. The core qualities of HTTP1.1 developed over a decade ago have opened the doors to several embarrassing performance and security loopholes for instance Cookie Hack.

Benefits of HTTP/2

Server Push

HTTP/2 uses a procedure called server push where servers understand which files the browser need before the browser requests for them.

The server will technically “push” these files to browsers before the latter can even request for them. This makes the entire process of retrieving all resources needed to run a website faster.

Multiplexing

One of the striking limitations with HTTP/1.1 is that it can only transfer one request per TCP connection at a time. This forces browsers to utilize multiple TCP connections to simultaneously handle multiple requests. With HTTP/2, multiple HTTP requests are now possible on just one TCP connection. This means that transferring resources to a website will be faster and more efficient.

Binary Protocols

HTTP/1.1 processes text-based commands to complete requests which may transmit excess data. HTTP/2 cuts down the amount of data transmitted by implementing it through the binary protocol which simplifies how a client’s computer interprets the transmitted information. This saves time translating information from a text to binary. This can significantly improve load time and overall performance.

Header Compression

For media-rich websites, clients have to push multiple header frames; this leads to latency and uses extraneous consumption of network resources. HTTP/2 addresses this issue by compressing a large size of redundant header frames. It uses HPACK compression which compresses individual value for each header before transmitting it to the server. It then searches the encoded information from a list of previously transmitted header values to reassemble the full header information.

Stream Prioritization

One of the weaknesses of HTTP/1.1 is the minification of CSS files and JavaScript. This is to reduce bandwidth and boost performance based on smaller file sizes.

The implementation of HTTP/2 prioritization allows clients to provide preference over particular data streams. This means that only the codes needed by a certain web page will be served to visitors. Since requests are simultaneous on HTTP/2, loading several small stylesheet files will not be a problem.

Thanks for reading 💜