Can I compress output by setting the zlib.output_compression
directive to on
, and then set the output_buffering
directive to off
?
Secondly I read that I can set a number value to the zlib.output_compression
directive which specifies a specific buffer size.
But what if I also set the output_buffering
directive to a different number value of bytes? What will be the max buffer size?
Yes, you can compress PHP output this way, but web-servers (nginx, Apache) can do such compressing more effective for all type of content (css assets, etc), not only PHP output :)
Yes, you can set zlib.output_compression to numeric value http://php.net/manual/en/zlib.configuration.php#ini.zlib.output-compression
This option also accepts integer values instead of boolean "On"/"Off", using this you can set the output buffer size (default is 4KB). As for max buffer size, you cant set it more than web-server can handle. For example, nginx use 4K or 8K output buffer. http://nginx.org/en/docs/http/ngx_http_fastcgi_module.html#fastcgi_buffer_size
ob_gzhandler compression level use zlib.output_compression_level, which is -1 per default, level 6 (The default value, -1, lets the server decide which level to use). But! PHP manual http://php.net/manual/en/function.ob-gzhandler.php said:
You cannot use both ob_gzhandler() and zlib.output_compression. Also note that using zlib.output_compression is preferred over ob_gzhandler().
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With