Sometimes 3rd party PHP code just refuses to launch. Actually, it happens quite often. If you have just copied it and it worked – it’s a good sign. This time it wasn’t the case.
After going through all the initial steps, it looked like it should work, but instead of usual runtime errors this PHP application, running on Apache 2.4.9 & PHP 5.5.12, started showing this:
ERR_CONTENT_DECODING_FAILED
Error 330 (net::ERR_CONTENT_DECODING_FAILED): Unknown error.
Google Chrome’s Developer tools –> Network looked empty for quite some time, but after a really long wait here is what I’ve got:
Quick googling explains that this error is shown when HTTP response headers claim that the content is gzip encoded, but it isn’t. Other sources say that this may happen when plain-text content is added before/after encoded content. So proposed solution is to disable content compression.
There are different examples, it mostly involve writing something like
1 2 |
SetEnv force-no-vary SetEnv downgrade-1.0 |
or
1 |
SetEnv no-gzip 1 |
to your .htaccess file. I was still getting same error, it made no difference for me.
What helped
Adding zlib.output_compression = On
to php.ini
helped me. Issue was solved.
Likely source of issue
I am not certain where and how compression was forced to be enabled (this is a big black box legacy PHP sources), but I have noticed it only throws this ERR_CONTENT_DECODING_FAILED exception when there are debug errors on the page.
Literally, setting display_errors = Off
in php.ini
fixes the issue as well. In my case it was some E_STRICT messages, so setting error_reporting = E_ALL & ~E_STRICT
there to disable displaying E_STRICT errors works too.
Now when this behavior doesn’t look like some random magic, I feel like I’m in control again, therefore I may sleep well. It works.