Say Hello to HTTP/2
HTTP/1.x has been around for a long time... a really long time. HTTP/2 hopes to alleviate the performance issues rampant in HTTP/1.x. Read on for more details.
Join the DZone community and get the full member experience.Join For Free
HTTP/1.x was born in 1999, and the web has evolved a lot in the last decade. Because of HTTP/1.x, the web has many performance issues, and many developers have found hacks to overcome it. Below are some of the hacks which we used to improve the web performance.
- As HTTP/1.x opens the new TCP connection for each request, downloading many files from the single server become more resource intensive causing a bottleneck for performance. To avoid it:
- Use the CSS sprites, in which you download a bigger image containing the smaller images in it and show/hide at the client side.
- Minify CSS and JS files and lossless compression of the images to reduce the number of bytes to download via network while reducing the resource download time.
- Merge the multiple CSS and JS files into one, so that the number of requests will be reduced.
- Host the assets like images into different domains or CDN, this way multiple servers will serve the content to the web page.
To help overcome performance problems addressed by the above-mentioned hacks, the Google team came up with SPDY(Pronounce as “SPEEDY”) protocol and the same technique is used as part of Google Chrome browser. Now, the same team thought to revamp HTTP/1.1 and proposed HTTP/2. The teams from Facebook, Amazon, and others came together to be part of the Hypertext Transfer Protocol working group Internet Engineering Task Force(IETF).
Now, Let's see what features HTTP/2 will provide.
- Multiplexing (Open a single TCP connection and reuse the same for other requests).
- Server Push (Pushing the content from the server to user agent, before the client is asking).
- Compression of HTTP headers.
- Prioritization of resource (download the highest priority resource first, then the other one).
- Binary framing layer (not compatible with HTTP/1.1)
Now, as web developers, we might have a lot of questions about adapting HTTP/2. Below are few of the questions.
- Is there any change to the HTTP status codes, HTTP methods, Header fields, etc..?
- Do I need to change my code to adhere to HTTP/2?
- Do I need to change my web server to work with HTTP/2?
- Do I need to change the web browser to utilize HTTP/2?
As developers, we don't need to think about question 1 and 2 from the above list. There are no changes to HTTP status codes, HTTP methods, header fields, etc. and we don't need to change our code that is working for HTTP/1.1. HTTP/2 has backward compatibility to work with HTTP/1.1. For Question 3 and 4, yes we need to change the web server and the browser to offer support for HTTP/2. Below is the information about the web servers and the browser releases.
- Mozilla Firefox provides support for HTTP/2 from Firefox release 36
- Google chrome provided support from release 40 onward
- Safari 8
- Internet Explorer supports HTTP/2 in version 11, but only for Windows 10 beta
- IIS, on Windows 10 offers full support for HTTP/2
- Since 2015, Nginx has been ready to support HTTP/2
- Apache—not sure when HTTP/2 support will be provided
If you have any more info about HTTP/2, you can discuss as part of comments. Till then, Happy Exploring!
Opinions expressed by DZone contributors are their own.