How to disable HTTP/2 in chrome or chromium?

2020-02-26 04:32发布

问题:

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:

回答1:

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.



回答2:

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



回答3:

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 :)