CodeIgniter "content encoding error" CodeIgniter "content encoding error" codeigniter codeigniter

CodeIgniter "content encoding error"


This issue is where the output buffering starts. The check for the config variable is in system/core/Output.php in _display(). It starts the gzipped buffering after a lot of code has already run. This leaves the potential for output to have occurred before it buffering starts.

With compress_output set to false it doesn't matter because nothing is encoded. With it set to true you end up with mixed content. Some output is encoded and some is not which causes the compression error.

There are two solutions:

1) You could leave compress_output set to false and add ob_start('ob_gzhandler'); to the top of your index.php file. This will ensure that all output is always gzipped, including errors.

2) The other solution is to add ob_flush(); before ob_start('ob_gzhandler'); in system/Output.php. This will gzip output when there are no errors and serve you unencoded content when there are errors.

I think 2 is the better solution and should be implemented by the CodeIgniter team. But if you don't want to muck with the system code (changes will go away when you upgrade) then 1 is the better solution for you.


This might be a long shot, but if you echo/print database output directly from your controller instead of sending it to the model you'll likely get error messages that have to do with output buffering. Are you echoing from your controller?


Putting the following line in config.php:

$config['compress_output'] = FALSE;

Solves it. The problem in my case was that I sent the post, but it did not recognize the FILLCATEGORIAS function. Inly by changing the $ config [ 'compress_output'] = FALSE; solved it.

THIS problem occurred when we send data using a POST request:

Failed to load resource: net::ERR_CONTENT_DECODING_FAILED

<script type="text/javascript">               $(document).ready(function() {                                       $("#idEmpresa").change(function() {                    $("#idEmpresa option:selected").each(function() {                        id = $('#idEmpresa').val();                        $.post("<?php echo base_url();?>Admin/fillCategorias", {                            idEmpresa : id                        }, function(data) {                            $("#idCategoria").html(data);                        });                    });                });            });        </script>