Detect browser if capable/enabled for http2 via javascript or php

懵懂的女人 提交于 2020-01-07 06:25:27

问题


I've checked on similar questions and found two options I can proceed with, however both have problematic issues.

if ( performance && performance.timing.nextHopProtocol ) {
    console.log('Protocol:' + performance.timing.nextHopProtocol);
} else if ( window.chrome && window.chrome.loadTimes ) {
console.log('Protocol:' + window.chrome.loadTimes().connectionInfo);
} else {
    console.log("Browser does not expose connection protocol");
}

The above code does return the protocol however, while using my chrome it supports http2 and is capable, but still returns http1.

On another solution is to compile a list of supported browsers and cross check the http_useragent, however the list should be checked in from time to time and also cross check the OS versions. since for example IE 11 on windows 10 works but for let's say lower version it wont.

来源:https://stackoverflow.com/questions/44842659/detect-browser-if-capable-enabled-for-http2-via-javascript-or-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!