Revision history for DetectingZlibOutputCompression


Revision [22951]

Last edited on 2016-05-20 07:38:43 by DotMG [Replaces old-style internal links with new pipe-split links.]
Additions:
The PHP manual [[http://uk2.php.net/manual/en/function.ob-gzhandler.php#AEN108092 | suggests the using of ZLib library]] is preferable to using ob_gzhandler. Now, I have no idea why one is preferable to the other (speed?, but then how widespread is zlib module in PHP installs for e.g.?), so I ask if anyone knows why. If a user has zlib installed, then another alternative is to use .htaccess:
~~&OK, I just found [[http://uk2.php.net/manual/en/function.ob-gzhandler.php#30159 | this comment]] explaining the difference. Basically it is simply to do with the fact that zlib.output_compression works in parallel with the script. BUT because we use ob_start() anyway, there is thus no difference between the two as I see it (and zlib.output_compression can be set on a per file basis as the later [[http://uk2.php.net/manual/en/function.ob-gzhandler.php#31243 | comments]]). If output buffering was ever turned off, then zlib.output_compression seems preferable. I did use zlib.output_compression with wakka without problems BTW, using the simple .htaccess method... --IanAndolina
Deletions:
The PHP manual [[http://uk2.php.net/manual/en/function.ob-gzhandler.php#AEN108092 suggests the using of ZLib library]] is preferable to using ob_gzhandler. Now, I have no idea why one is preferable to the other (speed?, but then how widespread is zlib module in PHP installs for e.g.?), so I ask if anyone knows why. If a user has zlib installed, then another alternative is to use .htaccess:
~~&OK, I just found [[http://uk2.php.net/manual/en/function.ob-gzhandler.php#30159 this comment]] explaining the difference. Basically it is simply to do with the fact that zlib.output_compression works in parallel with the script. BUT because we use ob_start() anyway, there is thus no difference between the two as I see it (and zlib.output_compression can be set on a per file basis as the later [[http://uk2.php.net/manual/en/function.ob-gzhandler.php#31243 comments]]). If output buffering was ever turned off, then zlib.output_compression seems preferable. I did use zlib.output_compression with wakka without problems BTW, using the simple .htaccess method... --IanAndolina


Revision [18325]

Edited on 2008-01-28 00:11:11 by DotMG [Modified links pointing to docs server]

No Differences

Revision [6719]

Edited on 2005-03-15 11:31:06 by DotMG [Use ini_get to avoid conflict of wikka and server output compression.]
Additions:
=====How to detect automatically if zlib.output_compression is set?=====
Wikka has a problem when zlib.output_compression is set. This is a simple technique to make wikka compatible and requires no action from administrator when the server environment changes :
%%(php)
$zlib_OC_is_set = eregi('On|(^[0-9]+$)', ini_get('zlib_output_compression'));
%%

Then add a condition %%(php)(&& (!$zlib_OC_is_set))%% when testing if $_SERVER['HTTP_ACCEPT_ENCODING'] allows gzip content encoding.
----
==Question:==
The PHP manual [[http://uk2.php.net/manual/en/function.ob-gzhandler.php#AEN108092 suggests the using of ZLib library]] is preferable to using ob_gzhandler. Now, I have no idea why one is preferable to the other (speed?, but then how widespread is zlib module in PHP installs for e.g.?), so I ask if anyone knows why. If a user has zlib installed, then another alternative is to use .htaccess:

%%<FilesMatch "\.(php|html?)$">
php_value zlib.output_compression 4096
</FilesMatch>%%

Also - what is the bug you are fixing here - any is it specific to Wikka, or a general bug? Is is browser dependant? I've used zlib.output_compression with wakka for ages without a problem. Thanks for any info! --IanAndolina

~&The use of output compression is a Wikka enhancement, and is absent in Wakka. That's why you had no problem with Wakka. This bug is seen in [[LetterSaladOutputWorkaround]], and is specific to Wikka. --DotMG
~~&OK, I just found [[http://uk2.php.net/manual/en/function.ob-gzhandler.php#30159 this comment]] explaining the difference. Basically it is simply to do with the fact that zlib.output_compression works in parallel with the script. BUT because we use ob_start() anyway, there is thus no difference between the two as I see it (and zlib.output_compression can be set on a per file basis as the later [[http://uk2.php.net/manual/en/function.ob-gzhandler.php#31243 comments]]). If output buffering was ever turned off, then zlib.output_compression seems preferable. I did use zlib.output_compression with wakka without problems BTW, using the simple .htaccess method... --IanAndolina
----

==Category==
Deletions:
=====How to detect automatically if zlib.output_compression is set?=====
Wikka has a problem when zlib.output_compression is set. This is a simple technique to make wikka compatible and requires no action from administrator when the server environment change :
%%(php) ob_start();
ob_start('ob_gzhandler');
$data = ob_get_contents();
if (strlen($data) != 0)
{
$_SERVER['HTTP_ACCEPT_ENCODING'] = "none";
}
else ob_end_clean();
ob_end_clean();%%

A more interesting usage is to change the ./wikka.php like this :
1) Remove the following lines from the bottom :
%%(php)if (strstr ($HTTP_SERVER_VARS['HTTP_ACCEPT_ENCODING'], 'gzip') && function_exists('gzencode') && ($wakka->config['allow_gzip']))
{
// Tell the browser the content is compressed with gzip
header ("Content-Encoding: gzip");
$page_output = gzencode($content, 9);
$page_length = strlen($page_output);
header('Content-Length: '.$page_length);
} else {
$page_output = $content;
}%%

2) Replace the ob_start() at the top of ./wikka.php by
%%(php)
ob_start(); //so that eventual error message from the next ob_start won't be printed.
ob_start('ob_gzhandler'); //test zlib.compression
$data = ob_get_contents();
$ob_gzhandler_is_ok = (strlen($data) == 0);
ob_end_clean();
ob_end_clean(); //close all possible opened buffers
$ob_gzhandler_is_ok ? ob_start('ob_gzhandler') : ob_start(); //and reopen buffer.
%%

----
==Question:==
The PHP manual [[http://uk2.php.net/manual/en/function.ob-gzhandler.php#AEN108092 suggests the using of ZLib library]] is preferable to using ob_gzhandler. Now, I have no idea why one is preferable to the other (speed?, but then how widespread is zlib module in PHP installs for e.g.?), so I ask if anyone knows why. If a user has zlib installed, then another alternative is to use .htaccess:

%%<FilesMatch "\.(php|html?)$">
php_value zlib.output_compression 4096
</FilesMatch>%%

Also - what is the bug you are fixing here - any is it specific to Wikka, or a general bug? Is is browser dependant? I've used zlib.output_compression with wakka for ages without a problem. Thanks for any info! --IanAndolina

~&The use of output compression is a Wikka enhancement, and is absent in Wakka. That's why you had no problem with Wakka. This bug is seen in [[LetterSaladOutputWorkaround]], and is specific to Wikka. Because it's prooved that Zlib is preferable to ob_gzhandler, we may not consider the second solution. But note that the first solution does not really use ob_gzhandler to compress output, it just detects if the use of output compression is safe or not. Thanks for the info. --DotMG
~~&OK, I just found [[http://uk2.php.net/manual/en/function.ob-gzhandler.php#30159 this comment]] explaining the difference. Basically it is simply to do with the fact that zlib.output_compression works in parallel with the script. BUT because we use ob_start() anyway, there is thus no difference between the two as I see it (and zlib.output_compression can be set on a per file basis as he later [[http://uk2.php.net/manual/en/function.ob-gzhandler.php#31243 comments]]). If output buffering was ever turned off, then zlib.output_compression seems preferable. I did use zlib.output_compression with wakka without problems BTW, using the simple .htaccess method... --IanAndolina
----

~~~&This page is a BAD IDEA. I tried it on different servers, and there are some configurations where calling ob_start('ob_gzhandler') after ob_start() makes all the script fail (The only output I had was <html><body></body></body>). --DotMG

==Category==


Revision [6657]

Edited on 2005-03-11 08:12:31 by DotMG [I abandon this idea...]
Additions:
~~~&This page is a BAD IDEA. I tried it on different servers, and there are some configurations where calling ob_start('ob_gzhandler') after ob_start() makes all the script fail (The only output I had was <html><body></body></body>). --DotMG


Revision [6608]

Edited on 2005-03-08 17:33:04 by JavaWoman [layout]
Additions:
~~&OK, I just found [[http://uk2.php.net/manual/en/function.ob-gzhandler.php#30159 this comment]] explaining the difference. Basically it is simply to do with the fact that zlib.output_compression works in parallel with the script. BUT because we use ob_start() anyway, there is thus no difference between the two as I see it (and zlib.output_compression can be set on a per file basis as he later [[http://uk2.php.net/manual/en/function.ob-gzhandler.php#31243 comments]]). If output buffering was ever turned off, then zlib.output_compression seems preferable. I did use zlib.output_compression with wakka without problems BTW, using the simple .htaccess method... --IanAndolina
Deletions:
~~&---OK, I just found [[http://uk2.php.net/manual/en/function.ob-gzhandler.php#30159 this comment]] explaining the difference. Basically it is simply to do with the fact that zlib.output_compression works in parallel with the script. BUT because we use ob_start() anyway, there is thus no difference between the two as I see it (and zlib.output_compression can be set on a per file basis as he later [[http://uk2.php.net/manual/en/function.ob-gzhandler.php#31243 comments]]). If output buffering was ever turned off, then zlib.output_compression seems preferable. I did use zlib.output_compression with wakka without problems BTW, using the simple .htaccess method... --IanAndolina


Revision [6607]

Edited on 2005-03-08 17:27:09 by JavaWoman [getting around the comma bug... (again)]
Additions:
~&The use of output compression is a Wikka enhancement, and is absent in Wakka. That's why you had no problem with Wakka. This bug is seen in [[LetterSaladOutputWorkaround]], and is specific to Wikka. Because it's prooved that Zlib is preferable to ob_gzhandler, we may not consider the second solution. But note that the first solution does not really use ob_gzhandler to compress output, it just detects if the use of output compression is safe or not. Thanks for the info. --DotMG
Deletions:
~&The use of output compression is a Wikka enhancement, and is absent in Wakka. That's why you had no problem with Wakka. This bug is seen in [[LetterSaladOuputWorkaround]], and is specific to Wikka. Because it's prooved that Zlib is preferable to ob_gzhandler, we may not consider the second solution. But note that the first solution does not really use ob_gzhandler to compress output, it just detects if the use of output compression is safe or not. Thanks for the info. --DotMG


Revision [6606]

Edited on 2005-03-08 17:26:09 by JavaWoman [getting around the comma bug...]
Additions:
~&The use of output compression is a Wikka enhancement, and is absent in Wakka. That's why you had no problem with Wakka. This bug is seen in [[LetterSaladOuputWorkaround]], and is specific to Wikka. Because it's prooved that Zlib is preferable to ob_gzhandler, we may not consider the second solution. But note that the first solution does not really use ob_gzhandler to compress output, it just detects if the use of output compression is safe or not. Thanks for the info. --DotMG
Deletions:
~&The use of output compression is a Wikka enhancement, and is absent in Wakka. That's why you had no problem with Wakka. This bug is seen in LetterSaladOuputWorkaround, and is specific to Wikka. Because it's prooved that Zlib is preferable to ob_gzhandler, we may not consider the second solution. But note that the first solution does not really use ob_gzhandler to compress output, it just detects if the use of output compression is safe or not. Thanks for the info. --DotMG


Revision [6600]

Edited on 2005-03-08 11:43:18 by IanAndolina [Reply to DotMG]
Additions:
php_value zlib.output_compression 4096
Also - what is the bug you are fixing here - any is it specific to Wikka, or a general bug? Is is browser dependant? I've used zlib.output_compression with wakka for ages without a problem. Thanks for any info! --IanAndolina
~~&---OK, I just found [[http://uk2.php.net/manual/en/function.ob-gzhandler.php#30159 this comment]] explaining the difference. Basically it is simply to do with the fact that zlib.output_compression works in parallel with the script. BUT because we use ob_start() anyway, there is thus no difference between the two as I see it (and zlib.output_compression can be set on a per file basis as he later [[http://uk2.php.net/manual/en/function.ob-gzhandler.php#31243 comments]]). If output buffering was ever turned off, then zlib.output_compression seems preferable. I did use zlib.output_compression with wakka without problems BTW, using the simple .htaccess method... --IanAndolina
Deletions:
php_value zlib.output_compression On
Also - what is the bug you are fixing here - any is it specific to Wikka, or a general bug? Is is browser dependant? I've used zlib.output_compression with wakka for ages without a problem. Thanks for any info!


Revision [6598]

Edited on 2005-03-08 11:25:41 by DotMG [Re: IanAndolina; Zlib.outputcompression]
Additions:
The PHP manual [[http://uk2.php.net/manual/en/function.ob-gzhandler.php#AEN108092 suggests the using of ZLib library]] is preferable to using ob_gzhandler. Now, I have no idea why one is preferable to the other (speed?, but then how widespread is zlib module in PHP installs for e.g.?), so I ask if anyone knows why. If a user has zlib installed, then another alternative is to use .htaccess:
~&The use of output compression is a Wikka enhancement, and is absent in Wakka. That's why you had no problem with Wakka. This bug is seen in LetterSaladOuputWorkaround, and is specific to Wikka. Because it's prooved that Zlib is preferable to ob_gzhandler, we may not consider the second solution. But note that the first solution does not really use ob_gzhandler to compress output, it just detects if the use of output compression is safe or not. Thanks for the info. --DotMG
Deletions:
The PHP manual [[http://uk2.php.net/manual/en/function.ob-gzhandler.php#AEN108092 suggests the using the ZLib library]] is preferable to using ob_gzhandler. Now, I have no idea why one is preferable to the other (speed?, but then how widespread is zlib module in PHP installs for e.g.?), so I ask if anyone knows why. If a user has zlib installed, then another alternative is to use .htaccess:


Revision [6592]

Edited on 2005-03-08 09:54:37 by IanAndolina [Question to DotMG]
Additions:
----
==Question:==
The PHP manual [[http://uk2.php.net/manual/en/function.ob-gzhandler.php#AEN108092 suggests the using the ZLib library]] is preferable to using ob_gzhandler. Now, I have no idea why one is preferable to the other (speed?, but then how widespread is zlib module in PHP installs for e.g.?), so I ask if anyone knows why. If a user has zlib installed, then another alternative is to use .htaccess:
%%<FilesMatch "\.(php|html?)$">
php_value zlib.output_compression On
</FilesMatch>%%
Also - what is the bug you are fixing here - any is it specific to Wikka, or a general bug? Is is browser dependant? I've used zlib.output_compression with wakka for ages without a problem. Thanks for any info!
----


Revision [6582]

The oldest known version of this page was created on 2005-03-08 08:17:10 by DotMG [Question to DotMG]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki