问题描述
我正在搜索一个脚本,该脚本可以检测访问者的浏览器是否启用了SPDY或HTTP/2.
I am searching for a script which can detect if the visitor's browser has enabled SPDY or HTTP/2.
类似于此.
推荐答案
理论上,一旦 nextHopProtocol
进入 ResourceTiming 和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.
这篇关于如何检测访问者是否正在使用HTTP/2或SPDY?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!