Brion Vibber:
Rene Pijlman:
An optimization would be to solve it the other
way around:
decide per request to not compress with ob_gzhandler when the
file is available in compressed form in the file cache.
ob_end_clean() would probably disable the handler correctly... you might
try slipping a call in and see if that does it. The comments in the
manual indicate that it may still _call_ the ob_gzhandler function (so
will modify the headers) but won't output any data.
The main potential problem with this would be that ob_gzhandler might
have a different idea of what accepts gzip than we do.
Another problem is zlib.output_compression which is set in
php.ini and cannot be turned off at the scripting level
(according to a comment in the docs). And I guess most users
will want to enable it to compress all requests, including
requests that cannot be served from the file cache. So I don't
think an implementation which serves compressed cached files
without the overhead of uncompress/compress is worth the effort.
I have attached a patch which fixes the compressed file cache,
by always sending uncompressed data to the output buffer,
leaving compression up to zlib.output_compression or
ob_gzhandler.
The effect of the patch is that the file cache can be enabled
with $wgUseGzip set to true or false. $wgUseGzip decides if the
files stored in the cache are compressed or not.
But I think there should be a comment in the documentation that
setting $wgUseGzip to true makes little sense. The idead of the
cache is to spend some disk space to reduce CPU-cycles, so why
would you then want to spend CPU-cycles to reduce that disk
space?
I also suggest to change this in DefaultSettings.php:
# We can serve pages compressed in order to save bandwidth,
# but this will increase CPU usage.
# Requires zlib support enabled in PHP.
$wgUseGzip = function_exists( 'gzencode' );
to:
# Should the file cache be compressed, in order to save disk
# space. This will increase CPU usage.
# Requires zlib support enabled in PHP. To enable, change
# this line to:
# $wgUseGzip = function_exists('gzencode');
$wgUseGzip = false;
With this patch applied, wfClientAcceptsGzip() will no longer be
used.
--
Regards / Groeten,
http://www.leren.nl
René Pijlman
http://www.applinet.nl