HTTP/2 vs HTTP/1.1
The first usable version of HTTP was created in 1997. It went through several stages of development, this first version of HTTP was called HTTP/1.1. In 2015, a new version of HTTP called HTTP/2 was created.
HTTP/2 solves several problems that the creators of HTTP/1.1 did not anticipate. In particular, HTTP/2 is much faster and more efficient than HTTP/1.1.
One of the ways in which HTTP/2 is faster is in how it prioritizes content during the loading process.
What is prioritization?
In the context of web performance, prioritization refers to the order in which pieces of content are loaded. Suppose a user visits a news website and navigates to an article.
Should the photo at the top of the article load first?
Should the text of the article load first?
Should the banner ads load first?
The order in which these page resources load affects how the user perceives page load time. for example, If the content that's most important to the user loads first, such as the image at the top of the page, then the user will perceive the page as loading faster.
How does prioritization affect performance in HTTP/2?
In HTTP/2, developers have hands-on, detailed control over prioritization. This allows them to maximize perceived and actual page load speed to a degree that was not possible in HTTP/1.1.
HTTP/2 offers a feature called weighted prioritization. This allows developers to decide which page resources will load first, every time
When a client makes a request for a webpage, the server sends several streams of data to the client at once, instead of sending one thing after another. This method of data delivery is known as multiplexing. Developers can assign each of these data streams a different weighted value, and the value tells the client which data stream to render first.
Some other feature's of HTTP/2 that make it faster than HTTP/1.1
Typically, a server only serves content to a client device if the client asks for it. However, this approach is not always practical for modern webpages, which often involve several dozen separate resources that the client must request.
HTTP/2 solves this problem by allowing a server to "push" content to a client before the client asks for it.
The server also sends a message letting the client know what pushed content to expect – like if Bob had sent Alice a Table of Contents of his novel before sending the whole thing.
Small files load more quickly than large ones.
To speed up web performance, both HTTP/1.1 and HTTP/2 compress HTTP messages to make them smaller. However, HTTP/2 uses a more advanced compression method called HPACK that eliminates redundant information in HTTP header packets
.This eliminates a few bytes from every HTTP packet which results in faster loading.
HTTP/1.1 loads resource one after the other, so if one resource cannot be loaded, it blocks all the other resources behind it. In contrast, HTTP/2 is able to use a single TCP connection to send multiple streams of data at once so that no one resource blocks any other resource.
HTTP/2 does this by splitting data into binary-code messages and numbering these messages so that the client knows which stream each binary message belongs to.