I want to try serving gzipped output !! (drupal 4.7.0)

GiorgosK - June 14, 2006 - 02:37

Is there a way ?

1) setting/module in drupal to help serve page requests as gzip
2) apache must be configured to do it automatically (how do I check if it actually does ?)
3) can configure/instruct your server to do it through php.ini or htaccess (how do I do it ?)

I have seen some discussion on this but its mostly quite old.

Is there a possibility to have cached pages gzipped in a future release ?

gzipped cache

com2 - June 14, 2006 - 08:12

I read this comment in common.inc:

**
* Store the current page in the cache.
*
* We try to store a gzipped version of the cache. This requires the
* PHP zlib extension (http://php.net/manual/en/ref.zlib.php).
* Presence of the extension is checked by testing for the function
* gzencode. There are two compression algorithms: gzip and deflate.
* The majority of all modern browsers support gzip or both of them.
* We thus only deal with the gzip variant and unzip the cache in case
* the browser does not accept gzip encoding.
*

Close

benthere - June 14, 2006 - 09:00

Check that link for the php.ini options to enable gzip compression.

They are:

zlib.output_compression "1"
zlib.output_compression_level "-1"

The first should be set to "1" to turn it on. The second, level, is how much you want it to compress: 1 is least compressed, 9 is most compressed, but expect the higher levels to put more load on the server than they're worth. -1 uses the default zlib setting, which is usually 6.

Once you've set that in php.ini, go to this page and enter your site URL to test that it worked:
http://www.gidnetwork.com/tools/gzip-test.php

-- Ben

Thanks for the responses

GiorgosK - June 15, 2006 - 12:45

Tried

1) .htaccess
php_value zlib.output_compression 1
php_value zlib.output_compression_level -1

2) creating php.ini
zlib.output_compression "1"
zlib.output_compression_level "-1"

3) and site/default/settings.php
ini_set('zlib.output_compression', '1');
ini_set('zlib.output_compression_level', '-1');

and the gidnetworks gzip test tells me there is no compression which is true since I was also checking the request and the responses of my browser (FF1.05.2) using HTTPDebugger

I see that the response details:
Transfer-Encoding: chunked (what does this mean ?)
Content-Type: text/html; charset=utf-8

while in the request details are:
Accept-Encoding: gzip,deflate (gzip accepted)

Any ideas how to achieve gzip compression ?
Is it worth it ?
I already increased my memory limit in settings.php
ini_set('memory_limit', '100M');
and show a big decrease in response time
(5 seconds max for anonymous user - 7-8 secs for admin user / previously it was anywhere from 12 - 30 secs)
is it worth doing it with caching enabled or disabled ?

--
chios sightseeings

Won't improve response time

benthere - June 15, 2006 - 13:11

From what I've read, gzip compression doesn't improve performance, because the extra load on the server negates any benefit of sending less data.

What it will do is lower your bandwidth usage. YMMV.

You can also try a different method:
http://www.php.net/ob_gzhandler

The code would probably have to go in /themes/yourtheme/page.tpl.php

Oh yeah, and check that you have the zlib extension installed. Create a file phpinfo.php:

<?php
phpinfo
();
?>

Open it in your browser after uploading. zlib will have its own section near the bottom if it's installed.

-- Ben

My sites load MUCH faster

cybe - July 23, 2006 - 22:16

My sites load MUCH faster with gzip on.

It seems I've finall got both cache + gzip working at the same time.

Looking at this again

GiorgosK - June 18, 2006 - 10:54

It actually works

Thanks benthere

php.ini
zlib.output_compression "1"
zlib.output_compression_level "-1"

I was looking at some pages that don't actually get gziped (/tracker)
while other do (main page)
is that possible ?

--
chios sightseeings

I used to just put

cybe - July 27, 2006 - 09:40

I used to just put ob_start("ob_gzhandler"); in either index.php or settings.php and it worked. But not since updating to the newest 4.7.2 it isn't happening anymore.

Something has changed? Anyone have any idea what it is please? Something in Drupal's innards turning it off again?

I've checked and gzipping still works on the server, but not inside my drupal.

you only need ob_gzhandler

vacilando - August 8, 2006 - 07:25

Hi,

If you have zlib and PHP 4 >= 4.0.4, you only need to use this one-liner:

ob_start("ob_gzhandler");

This will test whether the browser can receive it, and gzip it as needed.

It does work in the current Drupal if you put it in settings.php

Check if it works using this excellent tool: http://www.whatsmyip.org/mod_gzip_test/

Cheers,

Tomas

------
http://www.vacilando.org

PHP, JS and CSS

gremlinc5 - May 19, 2008 - 12:41

I don't know if I'm going off topic, but if you want to serve gzipped js and css files as well, and you don't have access to Apache's mod_gzip, you can try SmartCache.

It should work on every version of Drupal (4.7 as well).

 
 

Drupal is a registered trademark of Dries Buytaert.