GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 09-Apr-2003, 15:49
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough

Misleading Zlib Configuration Options info


Please disregard this post, the information is useless - see this post.

At the time of posting, this page at php.net lists the following in their

Table 1. Configuration options list:
Code:
zlib.output_compression "0" PHP_INI_SYSTEM|PHP_INI_PERDIR

This is misleading and most likely an error on the page.

If you look at this other page, you'll notice that the correct configuration option is listed under

Runtime Configuration as:
Code:
zlib.output_compression "Off" PHP_INI_ALL

I had the misfortune of reading the wrong info first and wasted a few hours worth of useless code

For anyone wondering what all this means, here's code that you can use at the top of your scripts (or in a global functions.php file) to http://www.desilva.biz/php/zlib.html "compress your PHP-driven web pages" even better than ob_start( ' ob_gzhandler' ) can:

PHP Code:

<?php

// compression
$c = ini_get( 'zlib.output_compression' );
if( empty($c) ):
  ini_set( 'zlib.output_compression', '1' );
  ini_set( 'zlib.output_compression_level', '9' ); /* levels, I think
    are between 0 (no compression) - 9 (maximum compression). 
    Meanwhile there's the '-1', which I think is the default
    compression level, whichever that is! */
endif;

/// the rest of your PHP code / script...
?>


With a little bit more thought you can make this into a sort of a compression switch for each of your scripts (and / or 3rd party scripts)!
  #2  
Old 09-Apr-2003, 16:37
jrobbio's Avatar
jrobbio jrobbio is offline
Regular Member
 
Join Date: Jan 2003
Location: Loughborough, England
Posts: 840
jrobbio will become famous soon enough
Wow that's cool JDS I searched for ages trying to find the line to insert for the compression level. The php.net help files were really ambigious and I ended up leaving them. Looks really useful. Not sure how a server would perform on level 9 though.
  #3  
Old 09-Apr-2003, 20:00
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
Quote:
Originally posted by jrobbio
Not sure how a server would perform on level 9 though.

If I were you, I wouldn't worry so much about how the server would perform with max compression - you don't need to, your web host will take care of that for you

Seriously? My new sites will use this and it will be at 9 until I find information to the contrary.
  #4  
Old 11-Apr-2003, 11:24
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough

zlib.output_compression != PHP_INI_ALL after all!


I was SO wrong, zlib.output_compression cannot be set using ini_set() after all!

It does change the (local) value in your phpinfo() (when ini_set() is used) but the page is NOT compressed!

So the only thing one can do is use the .htaccess file adding the following lines to it:

Code:
php_flag zlib.output_compression on php_value zlib.output_compression_level 9
This is what I have done for this site today...
  #5  
Old 11-Apr-2003, 11:30
jrobbio's Avatar
jrobbio jrobbio is offline
Regular Member
 
Join Date: Jan 2003
Location: Loughborough, England
Posts: 840
jrobbio will become famous soon enough
PHP Code:

php_value zlib.output_compression_level 9 




This is what I have been looking for. I'm going to try it in my .htaccess file. It makes things so much easier than having to try and change the code on my pages. Woo!
  #6  
Old 12-Apr-2003, 12:44
Garth Farley Garth Farley is offline
Awaiting Email Confirmation
 
Join Date: May 2002
Location: Ireland
Posts: 638
Garth Farley is a jewel in the roughGarth Farley is a jewel in the roughGarth Farley is a jewel in the rough
I think ini_set() isn't very useful, as most of the ini file options that you actually want to use are already applied before you call ini_set().

For instance, trying to set register_globals to of using ini_set() just doesn't work, as the the PHP predefined variables are already set before the script is even looked at.

Similarily with output compression setting, the php.ini's file will set up whatever compression is to be used, before the first line of the script is even looked at.

But I suppose it's handy for some settings, like you can change the colours that the syntax_highlight function uses, and other little things too. But nothing major.

GF
  #7  
Old 12-Apr-2003, 21:55
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
au contraire, there are many 'useful' uses for ini_set() at least I think they are useful - just not in the case of :

register_globals and zlib.output_compression

The reason was I think, because there was initial confusion when many of us looking to manipulate these very same settings found misleading information in the PHP Manual. i.e. for a while back then, the PHP manual stated that register_globals configuration was PHP_INI_ALL when this was clearly not the case.
  #8  
Old 06-Sep-2003, 13:38
BobbyDouglas's Avatar
BobbyDouglas BobbyDouglas is offline
Regular Member
 
Join Date: Aug 2003
Posts: 789
BobbyDouglas has a spectacular aura aboutBobbyDouglas has a spectacular aura about
Isn't there a way to do this in your .htaccess? Maybe I missed t he post about it, I thought I saw it on here tho.
  #9  
Old 06-Sep-2003, 16:17
jrobbio's Avatar
jrobbio jrobbio is offline
Regular Member
 
Join Date: Jan 2003
Location: Loughborough, England
Posts: 840
jrobbio will become famous soon enough
You can place
Code:
php_flag zlib.output_compression on php_value zlib.output_compression_level 9
within your .htaccess so you don't have to place it in every page yes. However, if you have the ob_gzhandler code on any page with this it'll cause all sorts of messed up rubbish being sent as it can't do it twice.

Also its important that you place all your flash files in a seperate folder with php_flag zlib.output_compression off so that it doesn't cause problems since it can't handle it.

There is a way to prevent gzip attempting different mime types but I can't find the resource at the moment.

Rob
  #10  
Old 11-Jul-2004, 18:26
zpeek zpeek is offline
New Member
 
Join Date: Jul 2004
Posts: 1
zpeek is on a distinguished road
Is there a better way too see if it is compressing the page then just timeing it?
 
 

Recent GIDBlogProblems with the Navy (Enlisted) by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 11:00.


vBulletin, Copyright © 2000 - 2010, Jelsoft Enterprises Ltd.