note 30159 added to function.ob-gzhandler
| From: | nospam at 1111-internet dot com | Date: | Sat, 08 Mar 2003 21:23:34 +0000 |
| Subject: | note 30159 added to function.ob-gzhandler | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-45009@lists.php.net to get a copy of this message | ||
Differences between zlib.output_compression and ob_gzhandler:
zlib.output_compression runs in parallel with script execution - it begins compressing as soon as it
receives any output from your script, and sends data to the client each time its buffer (4K by
default) gets full. ob_gzhandler (actually 'ob_start("ob_gzhandler");') will not
start compressing until the script flushes (or, usually, exits), and will in turn send the entire
compressed document at once - which makes it more susceptible to causing a perception of latency.
Advantage: zlib.output_compression
On the other hand, ob_gzhandler gives you script-level control allowing you to use it selectively or
to unset it after setting it in certain cases. Despite some documentation to the contrary,
zlib.output_compression does not appear to be able to be set or unset on a script level; you must
instead set it globally (in php.ini) or in your webserver configs or .htaccess files, possibly using
FilesMatch-type mechanisms to control which scripts it will or won't apply to - which could get
unwieldy for large projects - particularly those which employ PHP to produce images and other
non-text output in addition to normal text output.
Advantage: ob_gzhandler
Net advantage: depends on your particular needs. I'm trying zlib.output_compression for now,
but I miss the flexibility that ob_gzhandler would provide.
p.s. here's an Apache 1.3.* httpd.conf/.htaccess file snippet that demonstrates the syntax for
conditionally setting zlib.output_compression:
<FilesMatch "\.(php|html?)$">
# turn it on with the buffer set to 2K using php_value
php_value zlib.output_compression 2048
# or just turn it on using php_flag
# php_flag zlib.output_compression On
</FilesMatch>
--
http://www.php.net/manual/en/function.ob-gzhandler.php
http://master.php.net/manage/user-notes.php?action=edit+30159
http://master.php.net/manage/user-notes.php?action=delete+30159
http://master.php.net/manage/user-notes.php?action=reject+30159