HTTP/2 performance optimisation
There are some very significant changes going on in the world of the web. The browser protocol HTTP that your browser uses to connect to your website now has a new version – HTTP/2. This won’t affect the average user, however, it changes the way in which developers do performance optimisation.
From now onwards, there will be significant changes affecting performance optimisation, and we want to explain what can be done away with and why.
Firstly, HTTP/2 doesn’t require a new request for each file, and this is the single factor that dramatically changes performance optimisation guidelines. In the old world of HTTP1 / HTTP/1.1, it was essential to combine images, JS and CSS files in order to reduce the number of browser requests to the server. The number of request made, dramatically affected response speeds.
In the new world of HTTP/2, this type of optimisation is not needed and can be counterproductive.
Can I use HTTP/2 now?
Quite simply – yes. If your website is running on HTTPS, then all major current browsers support HTTP/2. You might have to change your server configuration, or your hosting provider can do this for you to make sure it supports HTTP/2, but that’s all. Older browsers might support HTTP/2, but your site would still work for them.
Should I use HTTP/2?
Yes – It’s considerably faster than HTTP1, and if you set it up correctly, most of your website visitors will benefit from improved loading times.
HTTP/2 and CDN?
Even when adopting the new HTTP/2 protocol, you’ll still need a CDN. CDN’s deliver content much more quickly and effectively than your average server, so your website would still benefit! If you use a proper CDN, then it will already support HTTP/2.
Performance practices that can be done away with.
The following performance practices are no longer needed with HTTP/2 and should now be dropped:
CSS and JS concatination
- As reducing the number of requests is no longer an issue, there’s no reason to do this anymore.
- Image spriting is the practice of combining several small images into a larger image so as to reduce the number of HTTP requests. This is a tedious process that carries significant overhead, HTTP/2 entirely removes the need for it.
This is a less common practice, although some heavy-duty websites used multiple CDN domains to serve their files.
This practice emerged partly because a browser could only open eight parallel connections to a server in the world of HTTP/1 and they’d want to serve more files in parallel.
Because HTTP/2 removes the need for parallel connections (there can be parallel downloads within one connection), this practice becomes counterproductive. The use of multiple CDN domains actually requires multiple DNS requests, which slow the site down instead of speeding it up.
Inlining CSS and JS
Inlining small bits of CSS and JS is a practice that was aggressively pushed by Google. In our HTTP/2 world, a request for a small file now has no extra overhead, so we can now do away with this practice.
Google PageSpeed and HTTP/2
Unfortunately, Google’s PageSpeed tool and many other web performance testing tools are slow in their adoption of HTTP/2, but they should be changing guidelines. If a simple HTTP/2 test shows you that a site is capable of using HTTP/2, quite a few of the site speed suggestions will become moot. Existing documentation speaks of “networking round trips” that simply don’t take place in an HTTP/2 environment.
Does your website support HTTP/2?
Find out more, click here – keycdn.