-->

Safari won't load some resources over http/2

2020-07-03 04:07发布

问题:

Http/2 is enabled on server and yesterday I noticed that on Iphone (IOS 10.2) does not load some resources with error:failed to load resource:connecting to server is not possible. When I connect Iphone to Mac there are no errors in console but simply result of some requests result imidiatelly in that error. Interesting thing could be the fact that resources which are not loaded are subdomain of real domain( CNAME to be correct). Site is on https. Server is Windows server 2016.

EDIT: We resolved this subdomain problem, but still there are requests from same domain that are not responding with any response.

I know IOS > 9.3 supports http/2 when resources are loaded over https but thing that resources which not working are not part of that domain could help to resolve this problem but I don't know how.

I know that probably problem is related to http/2 protocol because my android native appliacation also stopped working with error : java.io.IOException: stream was reset: PROTOCOL_ERROR . I resolved that problem by forcing my application to use http/1. Now works. But how to resolve that iphone safari problem?

I'm using ASP.NET Web Forms as backend (which supports http2 since ASP.NET 4.6 which I'm using).

回答1:

It seems that solution has been found. After few days of investigating disabling dynamic content compression helped.



回答2:

The answer has already been correctly provided here above by Vlado Pandžić. I cannot comment as I am new on this site, but I wanted to add something I found.

IOS less than version 11 does support HTTP/2. BUT! It will get stuck if the page is too big and compressed. I'm not sure what the cut-off is, but if you open a small page which has dynamic compression (Gzip or whatever) it will work fine. ASP or PHP etc, doesn't matter. Once the page reaches a compressed data size which requires multiple round-trips to pull the data, then Safari gets it's knickers in a twist.

It will literally go into an endless loop, hammering your server with requests. I was seeing thousands of page hits while Safari was just stuck on a blank white screen.

The problem for me, is that disabling dynamic compression on your entire website will result in penalties from Google for mobile-friendliness. Google wants you to have compression on, but you have to disable it for Safari, which sucks.

My solution to this was the enable dynamic compression on the entire website, but I used web.config file to disable it for specific pages which I know can be quite large in size.

<location path="large-page.aspx">
    <system.webServer>
        <urlCompression doDynamicCompression="false" />
    </system.webServer>
</location>

Good luck!

Matt



回答3:

You can also disable gZip and use brotli instead for compression, older versions of Safari don't support it so it seems to work.

https://github.com/saucecontrol/Brotli-IIS