Absolutely Tech

Icon

Yes!! Its absolutely tech…

[SOLVED] Flush(), ob_flush() not working in PHP (Disabling gzip through htaccess)

Flushing the output buffer doesn’t works in PHP sometimes no matter what you do. I had this code which would never work on my server but would perfectly fine on localhost. This was the code.

<?php
include('common.php');
ini_set('output_buffering','on');
ini_set('zlib.output_compression', 0);
//ini_set('implicit_flush',1);
ob_implicit_flush();
for($i=0;$i<10;$i++) {
      echo $i;
      echo str_repeat(" ", 500);
      ob_flush();
      flush();
      sleep(1);
}
?>


I knew this had to do with Server configuration as the php code was fine. Then after searching a lot I stumbled across a page where it said that my host had recently enabled gzip for all pages, I instantly knew this was the problem.

So I made a .htaccess file in the folder where this script was and entered the following:

SetEnv no-gzip dont-vary

Saved the file. And it started buffering.

Cheers!

Post to Twitter Post to Yahoo Buzz Post to Delicious Post to Digg Post to Facebook Post to MySpace Post to Reddit Post to StumbleUpon

Related posts:

  1. Make A PDF File In PHP (Convert HTML to PDF using PHP)
  2. Solution to “MySQL Server Has Gone Away” Problem
  3. Installing a web server package for PHP development
  4. Using CodeIgniter’s Email library separately
  5. [Solved] Absolute positioning and screen-resolution problem

Category: Programming, Tutorials, Web Development

Tagged: , , , , , ,

Leave a Reply