'Safari won't load some resources over http/2

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



Solution 1:[1]

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

Solution 2:[2]

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

Solution 3:[3]

This is quite an old thread, however, there's a better answer if you need don't want to cut off old iOS devices than disabling all compression for either this site (accepted answer) or for all browsers for a given resource (Matt Deemer).

A URL Rewrite rule can disable compression just for the resources and browsers that matter.

Recently, I wanted to move an established Classic ASP site, which can serve large, dynamically created resources, to HTTP/2.

The following rule allowed everyone but old WebKit versions to get the content compressed.

    <rule name="No compression for old WebKit">
          <match url="^(.+\.asp.*)" />
          <conditions>
              <add input="{HTTP_USER_AGENT}" pattern="AppleWebKit\/60[0-3]" />
          </conditions>
          <serverVariables>
              <set name="HTTP_ACCEPT_ENCODING" value="none" />
          </serverVariables>
          <action type="Rewrite" url="{R:1}" />
    </rule>

NOTES: WebKit/604 and greater do not have the http/2 - compression issue.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Matt Deemer
Solution 2 Matt
Solution 3 Scott H