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 :) http://nginx.org/en/docs/http/ngx_http_gzip_module.html
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
You cannot use both ob_gzhandler() and zlib.output_compression. Also note that using zlib.output_compression is preferred over ob_gzhandler().