当支持SPDY的浏览器收到HTTP2(H2)响应时会发生什么? [英] What happens when a browser that supports SPDY receives an HTTP2 (H2) response?

查看:491
本文介绍了当支持SPDY的浏览器收到HTTP2(H2)响应时会发生什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的直觉是,支持SPDY的浏览器会将其视为SPDY响应。但是,我能找到的最多是确保H2响应会优雅地降级到HTTP1.1。我正在考虑以面向H2的方式提供资产(多个请求,没有域分片等),但我确实需要支持一些非H2浏览器(例如Android 4.1的浏览器)。如果所有客户至少符合SPDY标准,我会没事吗?



奖金问题:混合协议是否有任何复杂问题?我们的网络框架不支持H2,但我正在考虑从CDN提供大部分资产。假设TLS。

解决方案

启用了SPDY或HTTP / 2的浏览器使用TLS扩展(较旧的NPN或新的ALPN) )通过TLS协商他们所说的协议。



客户端按优先顺序发送能够发言的协议列表(例如 h2,spdy / 3.1,http / 1.1 ),并且服务器在该列表中的那些协议中选择它也支持的协议(并且匹配安全性所需的约束)。



例如,如果您的旧浏览器不支持 h2 ,它将发送 spdy / 3.1,http / 1.1 ,服务器永远不会选择 h2 (即使它支持它)。
如果服务器不支持SPDY,则唯一剩下的选项是 http / 1.1 ,这就是HTTP / 1.1的优雅降级。



如果客户端请求说SPDY(而不是HTTP / 2),服务器将回复HTTP / 2,除非服务器上出现严重的实施错误。



SPDY正在逐步取消,支持HTTP / 2。例如,最近的Chrome版本不再支持SPDY



当您向不同的域发出请求并且服务器使用不同的协议时,没有任何复杂性:这是由浏览器透明处理的。



如果您的服务器可以说SPDY和HTTP / 1.1,并且CDN可以说HTTP / 2和HTTP / 1.1,那么您必须使用支持所有3种协议的浏览器来利用SPDY和HTTP / 2的好处。
浏览器可以与您的服务器协商SPDY,并与CDN协商HTTP / 2,以及由两个来源的资源组成的页面。



但是,浏览器很快就会丢弃(或者已经丢弃)SPDY,因此在最近的浏览器中,您最终可能会在服务器上使用HTTP / 1.1,而在CDN上使用HTTP / 2,从而失去服务器上资源的SPDY | HTTP / 2优势。 / p>

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.

解决方案

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.

这篇关于当支持SPDY的浏览器收到HTTP2(H2)响应时会发生什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆