9
votes

i am using the Gzip commpressionand Zlib commpression to speed up my website

I have used below code

ob_start("ob_gzhandler"); in common file that are include on all pages and

lib.output_compression = On

But after this i get the error like

"Warning: ob_start() [ref.outcontrol]: output handler 'ob_gzhandler' conflicts with 'zlib output compression' in E:\xampp\htdocs\projects\trunk\index.php on line 2"

Can any one suggest me what's wrong in it?

6
Hi,After searching on google i came to know Gzip and Zlib both can not work together. You to use any one from above .So what i did - lib.output_compression = Off So anyone know how to use both compression to webiste?CodePlateau

6 Answers

6
votes

You should check if the zlib library loaded then clean the turn off output buffering by doing ob_end_clean()
You can add this line in the top of your file : <?php if (extension_loaded('zlib')){ ob_end_clean(); ob_start('ob_gzhandler');} ?>

5
votes

Search line below in your php.ini file:

zlib.output_compression = On

change for:

zlib.output_compression = Off

0
votes

In your php.ini, search 'zlib' and toggle to On

0
votes

Recommendation : Dont use PHP Zlib compression, Turn it OFF

but try to Turn on Output Buffering

Which helps Processed HTML are Started to Buffer immediately without waiting.. Which helps to speed up some mili secs.

Dont use too much PHP echo for normal HTML codes.

Use

  • Webserver Gzip compressions
  • Minify the HTML outputs
  • Use Opcache and Static cache generators to Speedup your website 100% Gain.
-1
votes

It's the same. You only need to do one of them, not both.

-2
votes

I had the same problem and your answer was very helpful.

Search line below in your php.ini file:

zlib.output_compression = On

change for:

zlib.output_compression = Off

However I could not figure out where to locate the php.ini file or the zlib. I took a few days off and I looked over the above from a new perspective. My Hosting provider is "Hostinger" http://api.hostinger.in/redir/21246281 they use the New Control Panel and you will access PHP Configuration here: ps for cpanel users I will give an update if needed.

Here is an example of a php configure page on the Hostinger panel:


PHP Configuration


PHP version

PHP 5.2
PHP 5.3
PHP 5.4
PHP 5.5
PHP 5.6
PHP 7.0
Choose which PHP version you would like enabled for your account.

Zlib Compression

Enabled
Disabled

Whether to transparently compress pages. If this option is set to "On" in php.ini, pages are compressed if the browser sends an "Accept-Encoding: gzip" or "deflate" header. "Content-Encoding: gzip" (respectively "deflate") and "Vary: Accept-Encoding" headers are added to the output. In runtime, it can be set only before sending any output.

Display Errors

Enabled / Disabled This determines whether errors should be printed to the screen as part of the output or if they should be hidden from the user. Max Input Vars

Here is an example of the php configure admin panel page just make the change. Hope this was helpuful to someone. [email protected]