sNews Forum

Previous sNews versions => sNews 1.4 Final => Mods and Addons => Topic started by: iatbm on September 11, 2006, 12:22:56 am

Title: [MOD] Output compression (sNews All Versions)
Post by: iatbm on September 11, 2006, 12:22:56 am
include('snews.php');
ob_start("ob_gzhandler");
?>

If you want to :D
Title: [MOD] Output compression (sNews All Versions)
Post by: Patric Ahlqvist on September 11, 2006, 07:41:20 am
Hey, iatbm... Would you care to explain what this is, does, means to the regular user/newbie ??

Patric.
Title: [MOD] Output compression (sNews All Versions)
Post by: gomisan on September 11, 2006, 10:19:44 am
hehe, and others ;)
Title: [MOD] Output compression (sNews All Versions)
Post by: philmoz on September 11, 2006, 10:55:04 am
geez people, anyone would think you'd not heard of Google  :D
.. or php.net  :D :D

http://au.php.net/ob_gzhandler
Title: [MOD] Output compression (sNews All Versions)
Post by: PowerNight on September 11, 2006, 10:58:59 am
Yes I can explain. We talked about it here: http://www.internetmojster.com/viewtopic.php?id=29

and I asked iatbm to post this idea on snews 1.5 forum.

So the idea is to add "ob_start("ob_gzhandler");" to the start of index.php to enable gzip compression for webpages. Your pages will load up to 10 times faster, you will save bandwidth, but it will put extra stress on the server cpu. Test it, it works great on my page :)

I am not a programmer, so please ask google about "ob_gzhandler".

The top of index.php should look like this:

include('snews.php');
ob_start("ob_gzhandler");
?>
Title: [MOD] Output compression (sNews All Versions)
Post by: Patric Ahlqvist on September 11, 2006, 11:11:11 am
Ah, ok... first I will read the link provided by Phil-san. Power, thanks for the input, and welcome ;)... Stay on and enjoy. Will read that forum debate...

Now, what do we think about this: "but it will put extra stress on the server cpu." ? Safe, secure, too much load on server ? What ?
Title: [MOD] Output compression (sNews All Versions)
Post by: philmoz on September 11, 2006, 11:17:02 am
Suggest leaving it to the sNews user as to whether they want to use this....

That is... a  mini-MOD  ;)
Title: [MOD] Output compression (sNews All Versions)
Post by: iatbm on September 11, 2006, 11:41:39 am
Quote from: Patric
Ah, ok... first I will read the link provided by Phil-san. Power, thanks for the input, and welcome ;)... Stay on and enjoy. Will read that forum debate...

Now, what do we think about this: "but it will put extra stress on the server cpu." ? Safe, secure, too much load on server ? What ?
Since snews is not server intensive I think that gzip output will not do much harm. It is sure faster. As for security that is server side and since a lot of cms and forum software have this option I think it is secure.
Title: [MOD] Output compression (sNews All Versions)
Post by: PowerNight on September 11, 2006, 11:45:54 am
Hey Patric, thanx!

The pages have to be compressed by server first and then sent to browser. If you have a highly visited production site this might be an issue. It worked well (and sitll does) on 20.000+ page generations per day for my previous site. For greater load I don't know.
Title: [MOD] Output compression (sNews All Versions)
Post by: Patric Ahlqvist on September 11, 2006, 12:34:53 pm
Sounds great. I have also noticed a faster load. And that is nice, nice, nice ;)... So thanks Iatbm and Phil for posting this... I'm sure using it ;) (Til the bloody supplier tells me not too ;)...)
Title: [MOD] Output compression (sNews All Versions)
Post by: Smoothie on October 08, 2006, 11:27:55 pm
One of the best 'mods' posted here, thanks very much.  My site's loading noticeably faster, especially if I show a lot of posts on the main page.

Great tip! :)
Title: [MOD] Output compression (sNews All Versions)
Post by: sevir on October 17, 2006, 12:25:30 am
You only will have problems using old browsers such as Netscape 4, IE 4 and older (win 98 and win 95), lynx (this is not old browser, only text browser) but doesn't support GZIP compression.

You can get the same ob_start("ob_gzhandler"); using ini_set('zlib.output_compression', '1');

Anyway, only compress the text output, not graphics and other multimedia embedded objects, if you have not so much text, for compatibility is better not use GZIP compression.
Title: [MOD] Output compression (sNews All Versions)
Post by: ognennyjstorm on April 27, 2007, 05:13:42 am
Quote
session_start() will register internal output handler for URL rewriting when trans-sid is enabled. If a user uses ob_gzhandler or like with ob_start(), the order of output handler is important for proper output. For example, user must register ob_gzhandler before session start.

Note: Use of zlib.output_compression is recommended rather than ob_gzhandler()
PHP: session_start - Manual (http://ru2.php.net/manual/en/function.session-start.php)