Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Say Hello to HTTP/2

DZone's Guide to

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.

Free Resource

Learn how to build modern digital experience apps with Crafter CMS. Download this eBook now. Brought to you in partnership with Crafter Software

HTTP 2

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.

  1. Is there any change to the HTTP status codes, HTTP methods, Header fields, etc..?
  2. Do I need to change my code to adhere to HTTP/2?
  3. Do I need to change my web server to work with HTTP/2?
  4. 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.

Browsers

  • 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

Webservers

  • 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!

Crafter is a modern CMS platform for building modern websites and content-rich digital experiences. Download this eBook now. Brought to you in partnership with Crafter Software.

Topics:
http 2

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}