HTTP/2: What It Is and Why It Is Faster and Better

http2 τι είναι τι κάνει

The http protocol we all know has reached version 2, called http2. As we will see below, all the best practices that web developers used to make a website faster were based on limitations imposed by the http protocol. Now that http2 is here, many of these techniques need to be reconsidered. If we do that, we get even better website performance.

A little history

Work on http2 began in 2009, when some Google engineers looked into certain limitations of the http protocol. Here are those limitations:

  1. plain http does not allow simultaneous requests over a single TCP connection.
  2. plain http does not let browsers “choose” the resources they need to display a page faster.
  3. there was a need to compress and reduce headers, which http does not allow.
  4. there was a need for the server to send data to the browser before the browser even asks for it, so that later loading is much faster, which http did not allow.

With all this in mind, they created an early version of http2 called SPDY. SPDY essentially improved the plain http protocol by adding the features above. Over time http2 took on all the good practices of SPDY, and SPDY has since been withdrawn from all browsers. The big difference between them is that to use http2 in practice we need an SSL certificate.

What do I need to do to get Http2

All modern servers and browsers now support http2, so if you are not the server’s system administrator, you are probably already using it without realising. What you will notice when you use http2 is that the good practices you used for http may now actually hold back the new protocol. So what we really need is to optimise our websites to take advantage of what http2 offers.

Benefits and best practices for Http2

First of all, to use http2 we need to install https, in other words SSL. Next, a good way to take advantage of the protocol is to drop the practice of creating sprites for our images (combining them into one large image) to avoid making many requests. This method is no longer needed (with http2 it probably even slows our website down), since many requests can now be made at the same time, so the download will be faster than with one large image.

The method of inline images in CSS using data URIs to save requests is no longer needed either, since every request is now much faster and “cheaper”.  Following the same logic, one large CSS file and one JS file to save requests are no longer needed; these files can be loaded only on the pages that need them. So the home page loads just the home page’s CSS, with no need to load the CSS for the whole site  to save requests, because, as we said, a request is now “cheap”! Finally, domain sharding is a technique we should abandon, as it actually slows our website down (with it, we download many files from different domain names to open new connections and download the files faster).

HTTP2 at Web-Mate

From all of the above you can see that http2 is here to stay and makes our websites faster. At Web-Mate we were among the first in Greece to use http2 on ALL the websites we host, and you can now see the huge speed they reach, combined with the best practices we use. After a month-long upgrade of our servers, we were pleased to offer our clients something so new. This gives them the chance to stand out from the competition.

Leave a comment

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

Recent articles

Ελλάδα 2.0 Banner

Free e-book from Web-Mate on local marketing