In my PHP.INI, gzip compression already enabled. May I use ob_start('ob_gzhandler'); in my PHP pages? And whats different between these two?
In my PHP.INI, gzip compression already enabled. May I use ob_start(‘ob_gzhandler’); in my PHP
Share
Enabling compression like this:in PHP.ini can be done like this:
this will mean every page PHP serves will be compressed, which may or may not be what you want.
Using ob_start(‘ob_gzhandler’) however will only compress that particular buffer / page and will not affect anything else served by PHP.
Use the second method if you want to compress only certain output. Mixing the two will be pointless, and will probably just use extra CPU cycles trying to compress the already compressed output.
It could be that PHP is clever enough to only do the compression once, but it’s still a fruitless exercise to use both approaches together.
It’s usually better to enable compression in your web server, although this depends on what you are trying to achieve.