Optimizing Your Website With HTTP/2
A major change is taking place within the infrastructure of the internet. There is a new version of HTTP, which is the main protocol used by web browsers to connect to websites.
The new version is called HTTP/2 and although it’s probably not something the average person should be concerned about, it’s an important change for web developers. The new HTTP/2 protocol changes the way in which web developers optimize websites for performance.
In this article we will cover the changes between HTTP and HTTP/2 along with best practices that have changed or have now become obsolete.
What is different?
The main difference between HTTP and HTTP/2 is that HTTP/2 no longer needs to make a separate request for each file. This improvement makes a massive difference in the guidelines for performance optimization.
When using the previous protocols HTTP1 or HTTP/1.1, files for CSS, JavaScript and even sometimes images would be combined to reduce the amount of requests between the server and the browser improving load times and website speed.
In the newer HTTP/2 protocol the process of combining files is no longer necessary and can sometimes even result in a negative impact on your website.
Is HTTP/2 already available?
If you have a website that is currently using HTTPS, then the answer is yes. All of the major web browsers support the HTTP/2 protocol. You will need to first check with the company your website is hosted on to ensure they support HTTP/2 and then make some small configuration changes to your server, but essentially it’s as simple as that.
The downside is some outdated web browsers may not be able to support HTTP/2 but your website will still load on them.
Should my website be using HTTP/2?
Simply put, yes. HTTP/2 is significantly faster than the former HTTP1 and when it’s setup properly the majority of your website users will notice a dramatic improvement in your website’s performance.
Do I still need a CDN with HTTP/2?
Yes, HTTP/2 still requires a CDN. A CDN is capable of much faster content delivery than your server, meaning your website will still see tremendous performance benefits from using one. Almost every major CDN already supports HTTP/2.
Performance Optimization and Best Practices Changes
Here is a list of performance optimization and best practices that are no longer required when using the new HTTP/2 protocol.
Combining CSS and JavaScript files: Since multiple requests are not an issue with HTTP/2 there is no longer any reason to combine files to reduce the amount of requests between the server and the browser.
Image Spiriting: The tedious process of combining multiple small images into a single larger image to reduce the amount of requests is now completely unnecessary with HTTP/2.
Domain Sharding: Although it wasn’t a common process, some websites with a lot of traffic setup multiple CDN domains to serve files in parallel. The HTTP/1 protocol was limited to a maximum of 8 parallel connection and configuring multiple CDN domains allowed more files to be served in parallel, resulting in higher load times and overall better performance.
HTTP/2 removes the need for parallel connections entirely as a single connection can serve multiple downloads now, rendering this former best practice obsolete.
Inline CSS and JavaScript: This former best practice used to be pushed heavily by Google. However, with HTTP/2 small files requests no longer have any significant impact on load times making this former best practice no longer relevant
HTTP/2 and Google PageSpeed:
Google PageSpeed Insights is the goto tool for web developers that want to analyze and improve a website’s load times and over all user experience but the popular tool has been slow at incorporating HTTP/2 into the test results.
If your website is using HTTP/2 it makes a lot of Google’s site speed improvement suggestions useless. Google is of course aware of this issue and expected to update their page speed tool and web master documentation shortly to include HTTP/2.