mod_gzip is an Apache module which compresses static html pages
using Gzip, according to IETF standards for browsers that accept
gzip enconding (IE, Netscape, etc). mod_gzip may
accelerate the download time for pages 4/5 times
and I strongly suggest you use mod_gzip in your webserver.
However, due to a lack of a filtering mechanism between modules
in Apache 1.x.x, there is no way to compress PHP generated output
using mod_gzip. Therefore, we have to build our own compressing
engine in PHP. In this article, I will explain how to use PHP output
controlling functions to make your pages load FAST!
using Gzip, according to IETF standards for browsers that accept
gzip enconding (IE, Netscape, etc). mod_gzip may
accelerate the download time for pages 4/5 times
and I strongly suggest you use mod_gzip in your webserver.
However, due to a lack of a filtering mechanism between modules
in Apache 1.x.x, there is no way to compress PHP generated output
using mod_gzip. Therefore, we have to build our own compressing
engine in PHP. In this article, I will explain how to use PHP output
controlling functions to make your pages load FAST!
Introducing PHP output control functions
One of the best things in PHP4 is that you can tell PHP to buffer
all of the output generated in the script, so no content is sent
to the browser, until you decide to send it. You can use this function to
use header and setcookie functions, wherever you want in
your script. However, this is only a small advantage of the powerful
output functions.
all of the output generated in the script, so no content is sent
to the browser, until you decide to send it. You can use this function to
use header and setcookie functions, wherever you want in
your script. However, this is only a small advantage of the powerful
output functions.
<?php
void ob_start
(void);
?>
This is used to tell the PHP processor to redirect all the output to
an internal buffer. No output will be sent to the browser after
a call to ob_start.
an internal buffer. No output will be sent to the browser after
a call to ob_start.
<?php
string ob_get_contents
(void);
?>
This returns the output buffer in a string that you can echo to send the
accumulated output to the browser (after turning buffering off!).
accumulated output to the browser (after turning buffering off!).
<?php
int ob_get_length
(void);
?>
This returns the length of the output buffer.
<?php
void ob_end_clean
(void);
?>
Cleans the output buffer and also turns output buffering off. You
have to use this function before outputing content to the browser.
have to use this function before outputing content to the browser.
void ob_implicit_flush ([int flag])
Is used to turn on/off implicit flushing (default=off). If this is on, then
a “flush” is executed for every print/echo or output command and output
is immediately sent to the browser.
a “flush” is executed for every print/echo or output command and output
is immediately sent to the browser.