compression problem and wrong MIMIC

My server doesn't allow apache gzip / deflate so I had to compress my php/js/css files with php. However when I turn the option on in the config.php file I will get the below Fatal error when I try to call an ajax function, any ideas why I get this error message?

Quote:<b>Fatal error</b>: ob_start() [&lt;a href='ref.outcontrol'&gt;ref.outcontrol&lt;/a&gt;]: Cannot use output buffering in output buffering display handlers in <b>/home/xxxxxx/public_html/system/libraries/Exceptions.php</b> on line <b>160</b><br />
All my ajax pages uses a controller + model (no view) so maybe I can turn gzip off in the ajax page, if so how does it work?

My second question is quite weired, when I use the RewriteEngine to hide the index.php I will get the wrong MIME type on my only png file which I load from a css file, the below message is shown when I monitor the http traffic in google chrome:

Quote:Resource interpreted as image but transferred with MIME type text/plain.

This is my .htaccess:
RewriteEngine on
RewriteCond $1 !^(index\.php|(.*)\.js|(.*)\.png|(.*)\.jpg|(.*)\.gif|(.*)\.bmp|(.*)\.swf|(.*)\.css|robots\.txt|(.*)\.html|(.*).xml)
RewriteRule ^(.*)$ /u/index.php/$1 [L]

so if I comment out line 2 and 3 the MIMI type will work as it should, from what I see png files shouldn't get affected by the above code...

[quote author="Dennis_gull" date="1251816982"] any ideas why I get this error message?[/quote]

Just read the comment above the setting:
/* ...
| 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.
$config['compress_output'] = TRUE;
You must use a view, don't echo from the controller.
You could use a very simple view like this:

echo $ajax_data;

class Ajax_controller extends Controller {

    function some_function()
        $data = array('ajax_data' => 'some data');
        $this->load->view('ajax_view', $data);

I didn't think about reading the comment above the option Tongue
Thanks for pointing this out..

Any ideas on the second issue?

[quote author="Dennis_gull" date="1251845707"]I didn't think about reading the comment above the option Tongue
Thanks for pointing this out..

Any ideas on the second issue?[/quote]
For your first point I stumbled upon this code from some knowledgeable code/poster.
It solved one of my problems:
if (LOCALHOST) // DO NOT compress $result
     // display in view
  $_SESSION['zzz_before'] = strlen($result);
    $search = array
            '/\>[^\S ]+/s',    //strip whitespaces after tags, except space
            '/[^\S ]+\</s',    //strip whitespaces before tags, except space
            '/(\s)+/s'    // shorten multiple whitespace sequences
    $replace = array
    $result = preg_replace($search, $replace, $result);
    $result .= sprintf('%6.3f', $_SESSION['zzz_after'] / $_SESSION['zzz_before']) ;                                                            
     // display in view
    $_SESSION['zzz_after'] = strlen($result);


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.