Search code examples
http2

What's the best practices for making a Web application to support HTTP/2


I'm trying out HTTP/2 and would like to know if there's any best practices for making a web application take advantages of the new protocol in both:

  1. Server side and
  2. Client side

And... where (and when?) should I start? What are the least effort changes to take effort of HTTP/2

Update:

Assumption : Users are already using browser that support HTTP/2.

Update 2:

Some good resources on this topic:


Solution

  • You don't need any changes to your apps to deploy HTTP/2: most things will work out of the box.

    That said, here are a few tips that apply mostly if you are starting from scratch:

    • Start developing your application using HTTPS. You don't want to have problems with your URLs when you deploy your application because fetching some resources over http:// (e.g. Google fonts or any other CDN resources) does not work anymore. It takes five minutes with some tools (just google "Five minutes to HTTPS development URLs").
    • Consider if you want to host some resources that you would normally link to a public CDN in your own server. The main performance reason with HTTP/2 for linking to some assets in a CDN, if you are not hosting your entire site on that CDN, is that those resources may be already in the user's cache. If they are not, opening a new connection takes in average half a second.
    • Don't set up bundling. Set up instead HTTP/2 Push. And then go and grab your favourite module manager. Give a try also to web components and PolymerJS. They are simply awesome when you are not concerned about bundling and round-trips.

    If you are using a server that uses machine learning for configuring HTTP/2 Push automatically (e.g, ShimmerCat), then a third tip is to keep the structure of your web pages predictable.