I was wondering why the dynamic PHP pages of Drupal are not compressed using the lowest gzip compression setting? The lowest level of gzip compression uses a tiny amount of CPU resources for a huge decrease in page size.

Would placing the code:

include "./polls/poll_cookie.php";
ob_start("ob_gzhandler");

at the top of all .php files in the root directory work?

Thanks in advance.

Comments

bertboerland’s picture

i was unaware that php could gzip as well. but should we lay this functionality at the presentation layer: eg the webserver?

see for example //http://www.innerjoin.org/apache-compression/howto.html and i am quite sure iis and the likes will have this possibility as well.

--
groets

bertb

--
groets
bert boerland

marco’s picture

you can enable this option in php,
zlib.output_compression = on
probably you can change this in your .htaccess
otherwise you can change the php files or even header and footer in your theme

--
Marco

philbog’s picture

So, for the php-challenged out there,
just add this line to your .htaccess file:
php_flag zlib.output_compression On

This will attempt to compress pages for transfer, if the browser allows.

mike3k’s picture

Why isn't it in the standard distribution? I just did that today and I see a huge speedup. I'll see in a few days if it also reduced my bandwidth usage.

--
Mike Cohen, http://www.mcdevzone.com/

sepeck’s picture

posibly because it is not available on all hosts?

-Steven Peck
---------
Test site, always start with a test site.
Drupal Best Practices Guide

Steven’s picture

The reason we don't do global gzipping is because this feature can be done through mod_gzip for apache in a much better fashion. This will also gzip stylesheets and such.

However, gzipping of Drupal's cached pages will probably go into the next Drupal release. Cached pages are stored in the database, so they only have to be gzipped once. The cache table becomes smaller too. This is better than mod_gzip in this case.

teedog’s picture

Argh stupid me. I only meant to paste this line of code:
ob_start("ob_gzhandler");

see http://www.php.net/manual/en/function.ob-gzhandler.php for more information.