codeigniter project giving 303 compression error

codeigniter project giving 303 compression error  using -'php,apache,codeigniter'

Trying to setup a CodeIgniter based project for local development (LAMP stack), and once all the config file were updated (meaning I successfully had meaningful bootstrap errors for CodeIgniter), I get this error in my browsers:

Error 330 (net::ERR_CONTENT_DECODING_FAILED): Unknown error.
Content Encoding Error: The page you are trying to view cannot be shown because it uses an invalid or unsupported form of compression.

Just using wget to fetch the file works fine, no errors and I get the content I'm expecting. Not sure if this is something with CI and the Server, or just something weird with the project. Has anyone seen this before?

asked Sep 15, 2015 by AngGRRV
0 votes

4 Answers

0 votes

CodeIgniter seems to have its own method of gzipping its output (Why, I don't know, but I'm not very familiar with CI.)

According to this forum entry, such an error can occur when PHP error messages screw up the compressed content. Adjusting error_reporting to E_ALL ^ E_NOTICE did the trick there.

Update: There also seems to be a CI config setting:

$config['compress_output'] = FALSE;
answered Sep 15, 2015 by JoyBocanegr
0 votes

For IIS users it would be useful to check the errors within the PHP Manager log.

For me the error was file write permission denied. Had to grant the necessary permissions.

answered Sep 15, 2015 by MatStClair
0 votes

Not sure if my comment is valuable here, but I had a similar issue that I want to share with you, who knows may be it can help some of you.

For my project, I have activated the GZIP in my CI config file:

$config['compress_output'] = TRUE;

In the config file it is well said that:

| Enables Gzip output compression for faster page loads.  When enabled,
| the output class will test whether your server supports Gzip.
| Even if it does, however, not all browsers support compression
| so enable only if you are reasonably sure your visitors can handle it.
| VERY IMPORTANT:  If you are getting a blank page when compression is enabled it
| means you are prematurely outputting something to your browser. It could
| even be a line of whitespace at the end of one of your scripts.  For
| compression to work, nothing can be sent before the output buffer is called
| by the output class.  Do not 'echo' any values with compression enabled.

The "Do not 'echo' any values with compression enabled." is very important here.

However, my function needs to echo a json encoded array for my Ajax call.

In order to fix that, I have added the "exit" function after my "echo" into the function.

    echo json_encode($arr_ajaxResults);

Now, with this input, I don't face no more the "Content Encoding" error.

I hope it can help guys who have the same issue.

answered Sep 15, 2015 by LeoPPW
0 votes

My solution is:

text editors normaly use ascii codifications, I open the file with notepad++ and change the page codification to: utf-8 without BOM. And the page now is working good.

answered Sep 15, 2015 by AidCattanac