CodeIgniter Project Giving 303/Compression Error

后端 未结 2 1768

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

2条回答
  •  孤城傲影
    2021-02-09 09:42

    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);
        exit();
    

    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.

提交回复
热议问题