CodeIgniter Project Providing 303 / Compression Error

Trying to set up a CodeIgniter-based project for local development (LAMP stack), and as soon as the entire configuration file was updated (which means I had successful boot errors for CodeIgniter), I get this error in my browsers:

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

Just using wget to extract the file works fine, no errors and I get the content that I expect. Not sure if this is something with the CI and server, or just something strange with the project. Has anyone seen this before?

+7
php apache codeigniter
source share
4 answers

CodeIgniter has its own gzipping method for outputting it (why, I don't know, but I'm not very familiar with CI.)

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

Update: there is also a CI configuration setting:

 $config['compress_output'] = FALSE; 
+10
source share

Not sure if my comment here is valuable, but I had a similar problem that I want to share with you, who knows, maybe this can help some of you.

In my project, I activated GZIP in the CI configuration file:

 $config['compress_output'] = TRUE; 

It’s well said in the configuration file 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. | */ 

"Do not echo any values ​​with compression enabled." it is very important here.

However, my function must echo the json code for my Ajax call.

To fix this, I added the "exit" function after my "echo" to the function.

  echo json_encode($arr_ajaxResults); exit(); 

Now, with this input, I no longer encounter a Content Encoding error.

I hope this helps guys who have the same problem.

+5
source share

For IIS users, it would be useful to check for errors in the PHP manager log.

For me, the error was forbidden. Should have provided the necessary permissions.

0
source share

My decision:

normaly text editors use ascii codifications, I open the file using notepad ++ and change the page encoding to: utf-8 without BOM . And the page now works well.

0
source share

All Articles