且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何检测访问者是否正在使用HTTP/2或SPDY?

更新时间:2023-12-03 09:19:40

理论上,一旦 nextHopProtocol 进入NavigationTiming ,您应该能够检测到对根页面和其他资源的 h2 支持.

Theoretically, once nextHopProtocol lands in ResourceTiming and NavigationTiming, you should be able to detect h2 support for the root page and other resources.

自2016年6月6日起, nextHopProtocol 仅在Firefox的ResourceTiming实现中可用.在其NavigationTiming或Chrome,FF和Safari的NavigationTiming或ResourceTiming中均不可用.

As of 2016-06-06, nextHopProtocol is only available in Firefox's ResourceTiming implementation. It is not available in their NavigationTiming, or in either NavigationTiming nor ResourceTiming for Chrome, FF, and Safari.

因此对于今天的Firefox访问者来说,对于与HTML页面相同域中的其他资源,您可以查看 nextHopProtocol 是否为 h2 ,并推断HTML页面为 h2 .

So for Firefox visitors today, you could see if nextHopProtocol is h2 for other resources on the same domain as the HTML page, and infer that the HTML page is h2 as well.