PDA

View Full Version : gzip compression: howto


iAlex
04-21-2002, 02:58 PM
Greetings,

I have vbulletin running, of course, with gzip compression enabled. Since my connection is reasonably fast, I hardly notice a significant difference between php pages that are compressed (the forum) and those that aren't (the rest of the site).

But today traffic was soaring and the site was slooow, whereas the forum was ok. What I'm wondering is how can I set all the other php pages to use the compression, I assume it shouldn't be a problem since everything needed is already there, used by the forum. How can I "turn it on" for the rest of the site?

Let me know if you need any specific info.

Any help much appreciated!!!

whizkid
04-21-2002, 03:53 PM
Hi,

try setting following PHP code at the top of all PHP sites, whom you want to have GZ compression activated:

ob_start("ob_gzhandler");


whizkid

Scott MacVicar
04-21-2002, 04:10 PM
The site could have been slow due to the extra cpu time required to compress the content before sending it to the client.

The gzip compression is designed to reduce bandwidth which will reduce loading time for most people, less time to download page = faster loading.

I have noticed that with alot of users on all wanting gzipped pages that the server load jumps up a great deal.

iAlex
04-21-2002, 07:16 PM
whizkid, that's all it takes? Does that mean it uses the same settings (ie. compression level) as I have set for the forum?

And how do I check whether the compression is on or off, whether it's working or not?

Finally, does the code have to be the first line of code in the file, ie. before the html code starts? Or doesn't it matter where it is?

PPN, I am aware of that, but in this case I had in mind the compression. My site is on a large server with a lot more sites so the difference in load should not be spectacular. Moreover, I am quite convinced it was a question of bandwidth this time.

Scott MacVicar
04-21-2002, 07:55 PM
the code would have to be before any information was sent to the browser

whizkid
04-21-2002, 08:14 PM
Hi,

well it works for me ;). You could check by loadeing a page without the compression activated and then with the compression activated and see if it makes a difference.
I put my code before any output to the browser happens.


whizkid

Originally posted by iAlex
whizkid, that's all it takes? Does that mean it uses the same settings (ie. compression level) as I have set for the forum?

And how do I check whether the compression is on or off, whether it's working or not?

Finally, does the code have to be the first line of code in the file, ie. before the html code starts? Or doesn't it matter where it is?


PPN, I am aware of that, but in this case I had in mind the compression. My site is on a large server with a lot more sites so the difference in load should not be spectacular. Moreover, I am quite convinced it was a question of bandwidth this time.

wooolF[RM]
04-22-2002, 01:02 PM
]Originally posted by whizkid
Hi,

try setting following PHP code at the top of all PHP sites, whom you want to have GZ compression activated:

ob_start("ob_gzhandler");


whizkid erm... sorry for newbie question... do I have to set it in all php pages or in all templates or... ? I'm just lost...
If it's in templates, can I just set it in the header?

Scott MacVicar
04-22-2002, 02:04 PM
as long as you set it in a php file that is called on every page, i have a header.php file which is called on every page on my site, so you could just add it to that and as long as the script includes header.php it will run it.

iAlex
04-22-2002, 02:50 PM
It's not working. :( I copied one of your page that I assume are outside the forum and using the code you posted: http://www.php4-forum.com/php_tutorials/.

I made two versions, one with only the php code and the html and another with <? ob_end_flush() ?> at the very end. None of them work, I can't seem to load them in any of the browsers I've tried with. Have a look:
http://www.juventuz.com/home/gzip/

When I try to load either one, IE gives me a dns error. What do you think the problem is?

bigmattyh
04-23-2002, 06:30 PM
By the way, gzip will NOT compress images -- only text. So if the rest of your site has images galore, that could explain why you aren't seeing an improvement on the rest of your site.

iAlex
04-23-2002, 09:22 PM
Right now that is irrelevant because it's not working at all. *HELP*

But good point nonetheless, I am aware of that, however.

Pilot
06-03-2002, 01:00 PM
Be ideal to be able to set this on for certain user groups - I want a hack to allow VB GZIP for moderators but NOT for ordinary users (as the CPU load is too high) - anyone help?

JoshFink
07-04-2002, 04:34 PM
Ok.. I would love some help on this. I run vbPortal.. Ok no big deal, but the front page is not gzip enabled.

So I figure to make it gzip enabled you put the

ob_start("ob_gzhandler");

at the beginning of the index.php

and

ob_clean_end();

at the end of the index.php file.. Right?

Well, it just gives me a totally blank page.

Any thoughts on this? yes, I could post over at vbPortal, but I think it's more of an "any external page to vBulletin" kind of answer correct?

Thanks for all the help

Josh

JoshFink
07-27-2002, 09:09 PM
^^ bump

thanks

Josh

nghiasi
07-30-2002, 02:29 PM
Originally posted by PPN
as long as you set it in a php file that is called on every page, i have a header.php file which is called on every page on my site, so you could just add it to that and as long as the script includes header.php it will run it.


Is there a way we can tell is our host support gzip or not? :glasses: