browserhttpscdnhttp2spdy

What happens when a browser that supports SPDY receives an HTTP2 (H2) response?


My gut feeling is that a SPDY-capable browser will treat it as though it were a SPDY response. However, the most I can find is a reassurance that an H2 response will degrade gracefully to HTTP1.1. I'm considering serving assets in an H2 oriented manner (multiple requests, no domain sharding, etc.), but I do need to support some non-H2 browsers (e.g. Android 4.1's browser). Will I be OK if all the clients are at least SPDY compliant?

Bonus question: are there any complications involved with mixing protocols? We're on a web framework that doesn't support H2, but I'm considering serving most of our assets from a CDN. Assume TLS.


Solution

  • Browsers that are SPDY or HTTP/2 enabled use a TLS extension (either the older NPN or the new ALPN) to negotiate the protocol they speak over TLS.

    The client sends the list of protocols that it is capable to speak in order of preference (e.g. h2,spdy/3.1,http/1.1), and the server picks one protocol among those in that list that it also supports (and that match security required constraints).

    For example, if you have an older browser that does not support h2, it will send spdy/3.1,http/1.1, and the server will never pick h2 (even if it supports it). If the server does not support SPDY, the only option left is http/1.1, and this is what constitutes the "graceful degradation" to HTTP/1.1.

    There is never the possibility that if the client requested to speak SPDY (and not HTTP/2), the server replies with HTTP/2, unless gross implementation errors on the server.

    SPDY is being phased out in favor of HTTP/2. For example, recent Chrome versions don't support SPDY anymore.

    There are no complications when you you make requests to different domains, and the servers speak different protocols: this is handled transparently by the browsers.

    If your server can speak SPDY and HTTP/1.1, and the CDN can speak HTTP/2 and HTTP/1.1, then you have to use a browser that supports all 3 protocols to leverage the SPDY and HTTP/2 benefits. The browser can negotiate SPDY with your server, and negotiate HTTP/2 with the CDN, and the page composed of resources from both origins.

    However, browsers will soon drop (or have already dropped) SPDY, so with recent browsers you may end up speaking HTTP/1.1 with your server and HTTP/2 with the CDN, thereby losing the SPDY|HTTP/2 benefits for resources on your server.