Even Faster Web with HTTP/2
Over the last years we’ve seen a frequent updating of web browsers and web technologies. But they all depend on the main driving component – the HTTP protocol which is used to transfer data on the Web.
And while they constantly improve the way they operate, the HTTP protocol has not gone through any changes for 15 years now. That is why the news about a new HTTP, that is faster and catches up with the rest of the Web components, is a quite refreshing one.
HTTP 1.1 (dated 1999) has been powering up the Web for years now, but the time has come for something new, better and in line with the modern online world.
HTTP/2 is the new version of the HTTP protocol. This version is based on the SPDY protocol, developed by Google to speed up web sites. HTTP/2 is a modern protocol with a new way to transfer data between a web server and a web browser, which significantly speeds up the loading of web content. Some of the advantages of this new protocol are the following: improved speed, low bandwidth, better connection management and more.
• The protocol is now binary (01000110…), instead of text (GET /index.html)and uses multiplexing of the client-server communication.
Two new data transfer components are introduced – Frame (frame, containing the data) and Stream (the stream through which the frames are exchanged). The data between a web server and a web browser is divided into parts and is packed into frames before being sent via the HTTP/2-TCP connection. There are several types of frames – header frame, data frame and others.
The HTTP/2-TCP network connection is a communication channel in the virtual space between a client and a server. A large number of data streams can be created and utilized within this communication channel. The stream is an independent thread of consecutively arranged frames flying both ways between client and a server. The frames within a single stream carry the stream’s identificator (a unique stream number). Both ends of the communication connection – the server and the client may take and rearrange frames from a multitude of various streams at the same time.
With HTTP 1.1, a single web client may only request a single resource at a given time using an HTTP/TCP connection. Each of those sent requests is received and processed in a consecutive order. The new HTTP/2 uses multiplexing of the requests and many requests may be ”attached” to a single TCP connection at the same time. A priority may be assigned to each request. For example, some parts of the web site, such as the HTML code and the .css may be loaded before the images.
• Uses header compression.
To compress the header, a specially created HPACK algorithm is used. The decreased volume of the constantly transferred headers between a client and a server significantly decreases the loading time.
• Allows the web server to send data to the client by the server’s own initiative (server-push), even before requested.
This new function for the web server tremendously speeds up web content loading time. The web server may offer to the web browser the additional elements of the web page, without waiting for a specific request for that. Up until now, when a web browser received and read the HTML code of a web page, the browser would send additional request to the web server for the additional resources (for example images and scripts). Instead, the web server will now know what are the additional elements on the web page and will offer them to the web browser right away, without additional requests and lag.
In the HTTP/2 protocol there is an option that is sparing the mobile clients who may decline to automatically receive data from the server.
Firstly, the common thing between them is in the idea for a faster and more secure Web for all, but the most important thing is that the HTTP/2 is based on SPDY.
SPDY is an HTTP compatible protocol developed by Google in 2012 and is supported by several web browsers such as Chrome, Opera, Firefox, Internet Explorer 11, Safari and Amazon Silk.
Many of the capabilities of the SPDY protocol are implemented in the new HTTP version such as multiplexing of the requests, headers compression, stream priority, sending data from the server (server-push) and more.
Google announced their plans to migrate to HTTP/2 by the beginning of 2016, discontinuing the support of SPDY (Google: Hello, HTTP/2, goodbye SPDY).
In Internet Explorer SPDY is already in a deprecated status.
The HTTP/2 protocol is already supported by the most popular web browsers such as Mozilla Firefox and Google Chrome. The developers of both web browsers have announced that the support of the HTTP/2 protocol will only apply to instances where a secure connection is used (https).
HTTP/2 is supported and is activated by default since Firefox 34. In the settings page of Firefox, about:config, for the option “network.http.spdy.enabled.http2draft” the value should be true.
If you are using Mozilla Firefox you may see HTTP/2 in action right away by making sure the option above is activated, and by visiting any web site through a secure connection. Make sure the site also supports HTTP/2, for example Google Analytics.
To see which protocol is used when connecting to the web site, open the developer tool in Firefox – Tools -> Web Developer -> Web Console (or key shortcut Ctrl+Shift+K). You will see something similar. If necessary, reload the page after opening the console (Ctrl+F5):
While the HTTP/2 protocol is already supported by the most popular web browsers, some server applications are still waiting for implementation. For the time being, if you want to test the new HTTP, you can take a look at the complete implementations node-http2 (Node.js), http-2 (Ruby) and others.
For now we are still waiting for the Apache web server to officially include support for the new HTTP/2 protocol.