[php] Error 330 (net::ERR_CONTENT_DECODING_FAILED):

Recently we migrated to a new server. After 2 days, I got the following issues

1) We had a crash on a session table, which we easily fixed by reparing it

2) We run OpenX as our adserver, and it also crashed, but there is no evidence in error.log It let's you login, but at the moment of looking to dashboard.php, we get the:

Error 330 (net::ERR_CONTENT_DECODING_FAILED): (Google Chrome)

and

The page you are trying to view cannot be shown because it uses an invalid or unsupported form of compression. (Firefox)


OpenX uses the following services on PHP:

OpenX requires: http://www.openx.com/docs/2.8/adminguide/System%20requirements

OpenX uses the default PHP settings. However, server administrators sometimes change these settings. Before you install OpenX check that the following settings are correct:

magic_quotes_runtime must be off safe_mode must be off register_argc_argv must be on if you want to run maintenance via command line file_uploads need to be turned on to allow HTTP file uploads OpenX requires the following PHP extensions:

Either the mysql extension, or the pgsql. The mysqli extension is not supported. The ZLib extension, to convert links inside compressed Flash files generated by Flash MX. The FTP extension. If this is not present OpenX will try to simulate it, which can be a less stable solution.

The GD extension, to generate graphs on the Home page. If the extension is not enabled you will not be able to view graphs or statistics on your Home page. Either the openssl extension or an SSL-enabled curl extension are required in order to logon to the Home page. If SSL is not enabled you will receive an error message in the Home page, but there is no impact on operations.


Any clue on possible reasons or on how to gather more information will be much appreciated. Thanks

This question is related to php openx

The answer is


There is a bad Java bug that will cause this: https://bugs.java.com/view_bug.do?bug_id=JDK-8189789


codes need to save UTF8 without BOM while recording. Sometimes, written codes with (Notepad++) or other coding tools and use UTF8 encode, this error occurs. I'm sorry, I do not know English. This is just my experience.


I saw this error in combination with the PageSpeed module enabled. The PageSpeed module has a cache that can be gzip compressed. So apparently what can happen is that content gets double compressed.

In order to rewrite resources, PageSpeed must cache them server-side. Until 1.10.33.0, these resources had been stored uncompressed. To reduce disk usage, decrease server latency, support higher compression levels, and increase server throughput, the HTTPCache can automatically gzip compressable resources as they are stored in the cache. To configure cache compression, set HttpCacheCompressionLevel to values between -1 and 9, with 0 being off, -1 being gzip's default compression, and 9 being maximum compression. The default value is 9, maximum compression.

I solved it by adding this line to my PageSpeed config:

HttpCacheCompressionLevel 0

which disables the compression.


I had a bit of a dummy moment this morning when I realized what caused this issue for me.

The strange thing is that the request was failing in both Firefox and Chrome, but worked when I tried to access via Fiddler Web Debugger.

For me, the problem was I had mis-typed a character into one of the PHP files in the project. I didn't notice this until I checked Git for changes to the project.

In my case I had: m<?php runMyProgram(); ?>.

Once I erased the m, it started working again.


This error caused because of output buffering modules extension(ob_gzhandler) added. While output buffering use at starting ob_start() and ending ob_flush()

<?php   
    ob_start( 'ob_gzhandler' ); 
    echo json_encode($array);
    ob_end_flush();
?>

Use this:

<?php   
    ob_start(); 
    echo json_encode($array);
    ob_flush();
?>

In case anyone still hunting the cause of this hateful issue, there comes a solution to nail the causing file. https://www.drupal.org/node/1622904#comment-10768958 from Drupal community.

And I quote:

Edit

includes/bootstrap.inc:

function drupal_load(). It is a short function. Find following line: include_once DRUPAL_ROOT . '/' . $filename; Temporarily replace it by

ob_start();
include_once DRUPAL_ROOT . '/' . $filename;
$value = ob_get_contents();
ob_end_clean();
if ($value !== '') {
  $filename = check_plain($filename);
  $value = check_plain($value);
  print "File '$filename' produced unforgivable content: '$value'.";
  exit;
}

I enabled zlib.output_compression in php.ini and it seemed to fix the issue for me.


One more idea for anyone else getting this...

I had some gzipped svg, but it had a php error in the output, which caused this error message. (Because there was text in the middle of gzip binary.) Fixing the php error solved it.


I was experiencing this issue on a site and none of the other solutions in this thread helped. After some troubleshooting I found the local.settings.php had a closing tag with a space after it like so:

<?php
$databases = array(
  'default' =>
  array (
    'default' =>
    array (
      'driver' => 'mysql',
      'database' => 'xxx',
      'username' => 'xxx',
      'password' => 'xxx',
      'port' => '',
      'host' => 'xxx',
    ),
  ),
);
?>
 

Updating local.settings.php to the following resolved:

<?php
$databases = array(
  'default' =>
  array (
    'default' =>
    array (
      'driver' => 'mysql',
      'database' => 'xxx',
      'username' => 'xxx',
      'password' => 'xxx',
      'port' => '',
      'host' => 'xxx',
    ),
  ),
);

The closing "?>" PHP tag is not necessary here. If you choose to use a closing tag you must ensure there are no characters / whitespace after it.


Do you use the ob_start(ob_gzhandler) function? If so and If you output any content above the ob_start(ob_gzhandler) function, you'll get this error. You can don't use this function or don't output content above this function. The ob_gzhandler callback function will determine what type of content encoding the browser will accept and will return its output accordingly. So if you output content above this function, the content's encoding maybe different from the output content of ob_gzhandler and that cause this error.


It happens when your HTTP request's headers claim that the content is gzip encoded, but it isn't. Turn off gzip encoding setting or make sure the content is in fact encoded.


If you are to use the Codeigniter framework then just make this into config file:

$config['compress_output'] = FALSE;

And in php.ini configuration file, use:

zlib.output_compression=On

In my case it happened when adding a new application to IIS that needed to be proxied with Apache.

I needed to set ProxyHTMLEnable On to ProxyHTMLEnable Off to get the content. (It looks like some js code most have triggered the error, but this gave me at least something to work from.)

IIS is sending the page content Content-Encoding: gzip

<Proxy "http://192.168.1.1:81">
    ProxyHTMLEnable On   #> change this to Off
    ProxyHTMLURLMap  ...  ...
</Proxy>

A far more common answer is that you have some error that is getting appended to whatever your compressing. The solution is to set display_errors = Off in your php.ini file (Check in your terminal if it's On by running php --info and look for "display_errors")

That should do it. And, how do you discover what errors you're actually? Check your PHP error logs whenever you hit that route/page.

Good luclk!


Enable gzip compression in php.ini:

zlib.output_compression = On

And add this to your .htaccess file:

<IfModule mod_deflate.c>
  # Compress HTML, CSS, JavaScript, Text, XML and fonts
  AddOutputFilterByType DEFLATE application/javascript
  AddOutputFilterByType DEFLATE application/rss+xml
  AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
  AddOutputFilterByType DEFLATE application/x-font
  AddOutputFilterByType DEFLATE application/x-font-opentype
  AddOutputFilterByType DEFLATE application/x-font-otf
  AddOutputFilterByType DEFLATE application/x-font-truetype
  AddOutputFilterByType DEFLATE application/x-font-ttf
  AddOutputFilterByType DEFLATE application/x-javascript
  AddOutputFilterByType DEFLATE application/xhtml+xml
  AddOutputFilterByType DEFLATE application/xml
  AddOutputFilterByType DEFLATE font/opentype
  AddOutputFilterByType DEFLATE font/otf
  AddOutputFilterByType DEFLATE font/ttf
  AddOutputFilterByType DEFLATE image/svg+xml
  AddOutputFilterByType DEFLATE image/x-icon
  AddOutputFilterByType DEFLATE text/css
  AddOutputFilterByType DEFLATE text/html
  AddOutputFilterByType DEFLATE text/javascript
  AddOutputFilterByType DEFLATE text/plain
  AddOutputFilterByType DEFLATE text/xml

  # Remove browser bugs (only needed for really old browsers)
  BrowserMatch ^Mozilla/4 gzip-only-text/html
  BrowserMatch ^Mozilla/4\.0[678] no-gzip
  BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
  Header append Vary User-Agent
</IfModule>

We also had this problem when upgrading our system to Revive. After turning of GZIP we found the problem still persisted. Upon further investigation we found the file permissions where not correct after the upgrade. A simple recursive chmod did the trick.