PHP ob_gzhandler “Content Encoding Error”
You know sometimes how the simplest little issue holds you up for days? Well I’ve just had a doozy!
I’m maintaining an inherited CMS application that I’m still having to trust that some of the inner workings ‘works’ because it’s all a bit involved and I’m not getting paid to rip it all apart for the sake of it.
We’re deploying the app onto new servers - something that I’ve done a few times so I wasn’t scared - but this time I just couldn’t get it to work - calling up pages I was getting “Content Encoding Error” messages from Firefox, and generally not helpful responses from other browsers.
The app was using GZIP to compress output where browsers support it using ob_gzhandler I knew, and if I commented out the gzip bits it was working, but that wasn’t something I wanted to do - and I was determined to find out why the same codebase wasn’t working on this environment with almost identical configuration to others that it did work on.
To cut a long story short - there’s a configuration include called at the start of each page that’s not under version control (for obvious reasons), and on this server it somehow acquired a couple of line breaks at the end after the closing php tag, so it started the html output early. Nothing to do with double encoding or other potential issues I found when Googling.








