July 27, 2024

What are the advantages of HTTP / 2 over HTTP?

HTTP / 2 comes from google’s SPDY protocol.

The main idea is to speed up the downloading of pages.

Indeed, HTTP / 1 is quite slow, because it makes one TCP connection per object to download, but a TCP connection is quite slow to be established because of TCP’s three-way handshake.

Establishing a TCP connection requires 3 packets, it may not seem like much when you are lucky enough to be on a fast network, but not everyone, there are still billions of people who only have access to PSTN networks.

On some slow networks, a TCP connection can take more than a second to establish, and on a page that contains 30 or so objects, it can quickly add up to a minute.

To speed up the process, the general idea is therefore not to make one TCP connection per object, but a single TCP connection which will be used to send all the objects (pipelining).

On slow networks, this can save a lot of time.

 

What are the advantages of HTTP / 2 over HTTP?

And then while we do, the protocol improves on other points that needed improvement in HTTP / 1 such as:

  1. HTTP/2, the relatively new protocol/upgrade of HTTP/1.1 addresses the shortcomings, speeds up page load significantly and is widely supported by all major browsers and servers.
  2. While HTTP/1.1 practically allows only one outstanding request per TCP connection HTTP/2 is multiplexed, and allows using same TCP connection for multiple parallel requests.
  3. HTTP/1.1 duplicates data across requests (cookies and other headers) causing too much data redundancy and thus impacting performance. HTTP/2 on the other implements compression of headers to reduce data redundancy and thus improve performance.
  4. HTTPS/2, rather than waiting for clients to make requests, will implements server push of resources/assets like JS and CSS, when it believes these will be required and in this way avoids round tripping and improves performance.
  5. Finally, HTTP/2 is implemented only over TLS and it is the reason you must move your assets to HTTPS to enjoy the full benefit of HTTP/2

 

According to SearchEngineLand, the major advantages are:

  • Single Connection. Only one connection to the server is used to load a website, and that connection remains open as long as the website is open. This reduces the number of round trips needed to set up multiple TCP connections.
  • Multiplexing. Multiple requests are allowed at the same time, on the same connection. Previously, with HTTP/1.1, each transfer would have to wait for other transfers to complete.
  • Server Push. Additional resources can be sent to a client for future use.
  • Prioritization. Requests are assigned dependency levels that the server can use to deliver higher priority resources faster.
  • Binary. Makes HTTP/2 easier for a server to parse, more compact and less error-prone. No additional time is wasted translating information from text to binary, which is the computer’s native language.
  • Header Compression. HTTP/2 uses HPACK compressions, which reduces overhead. Many headers were sent with the same values in every request in HTTP/1.1.

All this put together, we get a much more efficient protocol.

Leave a Reply

Your email address will not be published. Required fields are marked *