Forum Moderators: coopster

Message Too Old, No Replies

ob_gzhandler generating garbage with SSI files

         

JohnKelly

8:05 pm on Jan 18, 2005 (gmt 0)

10+ Year Member



I've enabled ob_gzhandler in my php.ini and it does seem to speed up page load. However, when I include files in the HTML pages using SSI:

<!--#include virtual="/includes/header.php"-->

the portion of the page that would have been the output from the header.php script is garbage.

Any ideas?

coopster

1:14 pm on Jan 19, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



It works fine if you don't compress the page?

JohnKelly

1:36 pm on Jan 19, 2005 (gmt 0)

10+ Year Member



Yes, if I comment out the gzhandler in my php.ini it all works fine, since compression is turned off.

I'm wondering if the SSI files are somehow being compressed twice?

JohnKelly

2:12 pm on Jan 20, 2005 (gmt 0)

10+ Year Member



Bump

Is it possible for ob_gzhandler to only compress files in a certain directory, for example to restrict it to www.domain.com/abc/?

coopster

3:18 pm on Jan 21, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Yes, put the PHP directive in it's own Apache <Directory> Container or use an .htaccess file in that directory.

Also, I just realized what you are saying. Do you know that you cannot use both ob_gzhandler() and zlib.output_compression? Also note that using zlib.output_compression is preferred over ob_gzhandler().

See the notes on the ob_gzhandler() [php.net] pages for more information.

JohnKelly

7:50 pm on Jan 21, 2005 (gmt 0)

10+ Year Member



SOLUTION:

I ended up using zlib.output_compression as it was recommended over ob_gzhandler. I put the following two lines in an .htaccess file in the directory I wanted to compress:

php_flag zlib.output_compression On
php_value zlib.output_compression_level -1

It seems to work fine.

BTW, -1 compression level is the system default. It can range from 0-9 with 9 being the highest compression. I did not see much difference between -1 and 9 so I left it at -1 (default).