I recently upgraded Aapche to 2.4.26 (ondrej ppa) on Ubuntu 16.04. By default, modules deflate and http2 are enabled.

On Chrome, when serving large JS files, the request simply does not finish and fails with net::ERR_CONNECTION_CLOSED after a long time has elapsed (essentially, time specified by Apache Timeout setting). On Firefox, everything runs perfectly.

What I have tried

I observed during troubleshooting:

  • Small JS files work fine. The large JS file I had was 259.43KB (75.78KB gzipped)

  • If I disable HTTP2 in Apache: Protocols http/1.1, Chrome works.

  • If I manually disable gzip module: a2dismod deflate, Chrome works.

Of course, neither option is ideal for performance.

As a shot in the dark, I tried to turn off KeepAlive as suggested by the answer in this question: https://stackoverflow.com/questions/25847083/chrome-just-doesnt-finish-loading-js-files. It doesn't solve the problem.

I copied the HTTP headers of the problematic JS file From Chrome Developer Tools:

HTTP Request Headers

:authority: example.com
accept-encoding:gzip, deflate, br
user-agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36

HTTP Response Headers

content-type:application/javascript; charset=utf-8
date:Mon, 03 Jul 2017 07:23:27 GMT
last-modified:Thu, 01 Jun 2017 14:49:09 GMT

I did some reading and it could have something to do with chunked gzip responses lacking Content-Length response header. It may also be due to lack of Transfer-Encoding response header. But I'm not sure what is the correct thing to do, or how to make Apache output those headers.


what seems to be the problem? How can I enable HTTP2 with gzip on my Apache web server?

If it is caused by wrong/missing headers for chunked gzipped HTTP2 responses, can anyone elucidate which headers are required? i.e. what is the correct way to serve chunked gzip HTTP2 responses?


This is a known bug in Apache, I am currently working on. See https://github.com/icing/mod_h2/issues/143

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.