Why does ob_start('ob_gzhandler') break this website?

Jrgns picture Jrgns · Mar 26, 2011 · Viewed 11.6k times · Source

I've got a site that throws a Content Encoding Error in the browser if a ob_start('ob_gzhandler') is present. If I remove the statement, it runs fine.

  • The site runs off the same framework, server and hosting package as a number of other sites. They all work, regardless of if the statement is in there.
  • The statement is in the framework, not the application code, so it is shared by all of the sites.
  • There's no difference in the configuration between the working sites and non working site.
  • The site runs fine locally, using the exact same code and data.
  • You can fetch the site with curl / wget, and the HTML returned renders fine in a browser.
  • The response headers are exactly the same, with out without the statement.

I've now removed all of the code on the remote server, and re-uploaded everything. Still no change. The next step would be to re-install the site, and start from scratch, but I don't want to loose all of the data.

Any pointers, suggestions or solutions?

Answer

diEcho picture diEcho · Mar 26, 2011

usually I do below and it works for me, give it a try

Write ob_end_clean(); or ob_flush(); at the bottom of the page where you start ob_start();

References:

ob_end_clean();

ob_flush();