Helpful Information
 
 
Category: vB3 General Discussions
[RELEASE] GZip Compression for vB 1.x

I was playing around with this for a site I'm building, and it occured to me that it would work fine for vB 1.x too, so here you go.

Open your admin/config.php and paste the following code at the end of the file, before the ?> tag.


<?php

// original bits of config.php go here

$gziplevel = 1;

function compress_output($output) {
global $gziplevel;
return gzencode($output,$gziplevel);
}

if (strstr($HTTP_SERVER_VARS['HTTP_ACCEPT_ENCODING'], 'gzip') && ($gziplevel != 0)) {
ob_start("compress_output");
header("Content-Encoding: gzip");
}
?>

This code is adapted from the reference script at zend.com, but with the addition of the ability to set the zip compression level. You can alter the line $gziplevel = 1; to use any number between 0-9 (0 is no compression), but i've found that for my site, a level of 1-3 gives the best balance of speed against CPU loading.

Once you have installed the code snippet, you can test that it's working by a) trying to access your forums b) inputting your URL here (you need to specify the .php file, rather than just the directory) http://leknor.com/code/gziped.php

Of course, you will need to have PHP built with zlib support for this to work. Find out by running a phpinfo() script...

If you have PHP 4.04pl1, and you want to just compress ALL php on your site, edit your php.ini file to read this:
output_handler = ob_gzhandler

Have to have PHP 4.04pl1, and compile it to use zlib...

Chris

Dosn't work for me, I just get a blank screen.

The Site is on Datablocks.net

If I set it to 1 it works

2 or above gives me a blank screen :(

wow! even with it set to 1, the difference was noticed

For me it doesn't work with 1 either... :(

Originally posted by -saturn-
For me it doesn't work with 1 either... :(

You're server must have php4 and zlib :D

I'm hosted at www.nomontlyfees.com

I know they have php4, but how can I find if they have zlib?

Easy! Go to yourdomain.com/forum/admin/index.php?action=phpinfo

You should find something like this:

I'm sorry to say but I didn't find it...

Where can we get zlib?

ftp://ftp.freesoftware.com/pub/infozip/zlib/zlib.tar.gz

if you prefer RPM:
ftp://ftp.rpmfind.net/linux/ASPLinux/i386/RPMS.09182000/zlib-1.1.3-6.i386.rpm

thanks

Just a little hint for you all...

Don't do this UNTILL you have vB installed and Working.

Here's my Directory Structure

# 127.0.0.1
|-- www
|----root
|------vbulletin1
|------vbulletin2
|------vbulletin3
|------vbulletin4

Thats on my local machine. I messed up installs 2 & 3 so i deleted all the files, unzipped and copied over again.

Ran the install and got GOBBLE! Then I realised. Just a reminder :p

Careful, guys. PHP4.0.4pl1 has a memory leak in it's zlib implementation. A lot of heavy-load website have crashed already because of it.

You might wanna wait til it's fixed.

For what it's worth, I have been watching this carefully and have had no problems with PHP Version 4.0.1pl2
running on FreeBSD 4.2.

The method I'm using is placing ob_start(ob_gzhandler); at the top of all my files.










privacy (GDPR)