简体   繁体   中英

How to disable HTTP/2 in chrome or chromium?

I'm trying to debug difference between HTTP/1.1 and HTTP/2. Is there any possibility for disabling HTTP/2 in chrome or chromium? I couldn't find this option flag in chrome 56. I have tried chromium 58 with flag --disable-http2 :

./Chromium.app/Contents/MacOS/Chromium --disable-http2

But content is still delivered with HTTP/2 protocol after using this flag:

铬 --disable-http2

For what it is worth, the flag works.

The issue is that you need to quit EVERYTHING Chrome for it to take effect. Including plugin shims and other chrome tabs and so on.

It is not enough just to add the command line switch.

An easier way to achieve something broadly equivalent is to use an HTTP Proxy, like https://www.telerik.com/fiddler . This adds negligible additional time to your requests, and (as far as I know) doesn't support http/2 at all (yet); even if it did, I'm pretty sure it would be much easier/practical to switch behavior in than restarting all your Chrome windows.

The advantage of this approach is that it takes effect immediately - disabling and reenabling HTTP/2 becomes as easy as starting and stopping the proxy, without messing with the (if you're anything like me) dozens of Chrome tabs you have open, to StackOverflow and elsewhere :)

What happens when you try doing the same thing in WebPageTest (select Chrome as the test agent and add the command line switch in the Chrome tab under advanced settings)

Here's a test I did for my personal site just now and the flag appears to work OK (if you look at the response headers you'll see HTTP/1.1)

https://www.webpagetest.org/result/170322_1B_ab8656afcfb8bcc4103e9872ff56c28b/1/details/#waterfall_view_step1

I have seen the same problem created by a firewall running in proxy mode vs flow mode.
The firewall would buffer the entire file so it could scan it then pass it along vs scanning the individual packets.

https://docs.fort.net.com/document/fortigate/6.4.4/administration-guide/721410/inspection-modes

The problem would only happen when using http2 and might have something to do with http request priority not being handled properly or it forced it single threaded.

We would have a video request start with a low priority that would stall then start causing other file downloads to be delayed. Then there was a api poler in the background coming in with high priority requests. After a few high priority requests were blocked chrome would cancel the low priority video.

It would happen in other cases but the video made it very reproduceable for us.

https://medium.com/dev-channel/javascript-loading-priorities-in-chrome-57c54cfa6672 https://blog.cloudflare.com/better-http-2-prioritization-for-a-faster-web/ https://blog.cloudflare.com/http-2-prioritization-with-nginx/ https://calendar.perfpl.net.com/2018/http2-prioritization/

We set it back to flow mode on the firewall and the problem went away. Afterwards the downloads all happened in parallel with no blocking or stalling in the chrome.network waterfall.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM