Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

zlib.output_compression and output_buffering

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?

like image 610
user3021621 Avatar asked Aug 18 '14 12:08

user3021621


1 Answers

  1. 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 :)

  2. 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

  3. 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().

like image 76
Aleksey Deryagin Avatar answered Oct 24 '22 06:10

Aleksey Deryagin