Linux Administrator - Apache, Perl, and Autoflushing

Linux Administrator

Privacy Policy

RSS Feed

Acoustic Guitar Tips
Anna Kendrick
Beekeeping Tips
Catherine Zeta Jones
My View On Things
Cheap Auto Insurance
Cheap Places to Live
Delta Shaper
Easy Wood Projects
Felicity Jones
Free Sheet Music
Funny Clean Jokes
Healthy Carbs
Heidi Klum
Improve Your Credit
Ivory Tower Group
Keke Palmer
Linda Ronstadt
Linux Administrator
Money Spigot
Nicole Kidman
Planet Cabinet
Quality Dating Advice
Rustic Cabinets
Sacramento Hiking
Sandra Bullock
Spintax Tool
The Actress
Tristan Prettyman
Viola Davis
Who Are The Beatles

Apache, Perl, and Autoflushing

Apache, Perl, and Autoflushing

OK, you're adminstering an Apache web server and you've just gotten a complaint from someone about how their perl script isn't displaying an updated status or progress of what it's doing. Instead of displaying a new line each time it iterates through its chores, the script waits until what it's doing is completely done and then puts it all the status messages on the screen at the same time.

If you have a time where you want to display data as it appears, this situation is not good at all. What you need to do is turn auto-buffering on.

In Apache, and probably other web servers, this is done by by including a line like this in your script:


This is supposed to tell your web server to not buffer data. Problem is, Apache might ignore the command. In order to remedy that, turn off the deflate module, which by default is turned on in a base installation of Apache. Do this using this command:

a2dismod deflate

Then, restart the Apache server:

/etc/init.d/apache2 restart

And here is an example of a perl script that should work properly:

Here's the script without $|:


Here's the script with $|:


Return To Main Page