HTTP/2 is the first major revision of HTTP (Hypertext Transfer Protocol) in the last 15 years. HTTP is the backbone protocol of the web that standardizes the way in which an application connects to a server to transfer Hypertext.
HTTP/2 is based on Google’s SPDY, which was created in 2012 as an experiment in speeding up web request. It provided for multiplexing over one connection, the compression of web headers, and a means of pushing content directly to a browser. Akamai set up a great demo to see the difference in performance.
Caniuse.com reports that 71% of browsers support HTTP/2 globally. Inherent in its design, the first request comes as a standard HTTPS request; older browsers will still transfer over 1.1 as usual. The biggest issue with support will be over the newer SSL standards required on newer browsers.
Setting up HTTP/2 is easy with Nginx version 1.9.5 or above.
nginx -v
Setting up or modifying a site that has SSL can be accomplished in two steps. If you need a SSL certificate you can setup a self-signed certificate or by using Lets Encrypt to create a valid free SSL certificate. To enable HTTP2 in your Nginx site configuration, simply add HTTP2 after SSL.
server {
listen 443 ssl http2;
...
}
Restarting Nginx followed by testing in Chrome is made easier by using a net-internals tab.
chrome://net-internals/#http2
This extra performance has changed the way we currently build sites, because there is no longer a need to concentrate javascript & css files. This has the benefit of improved caching as a small change in one file doesn’t require the entire js or css to be invalidated. Image spriting is no longer needed, although one would argue that it is still useful as the image overhead is reduced by the concentration of multiple images.
The largest change is domain sharing (loading assets from multiple domains). Under HTTP/2 this actually has a negative impact on performance. It is much better to load as many assets through a single domain, then to open multiple SSL connections to pull in assets.
Some of the biggest names on the web have already add support CloudFlare, Akamai & Wordpress.
Still missing from Nginx implementation is the optional asset push in the new standard.