gpt4 book ai didi

php - zlib.output_compression 和 output_buffering

转载 作者:可可西里 更新时间:2023-11-01 13:17:39 24 4
gpt4 key购买 nike

我可以通过将 zlib.output_compression 指令设置为 on 来压缩输出,然后将 output_buffering 指令设置为 off?

其次,我读到我可以为指定特定缓冲区大小的 zlib.output_compression 指令设置一个数值。但是,如果我也将 output_buffering 指令设置为不同的字节数怎么办?最大缓冲区大小是多少?

最佳答案

  1. 是的,您可以通过这种方式压缩 PHP 输出,但是网络服务器(nginx、Apache)可以对所有类型的内容(css Assets 等)进行更有效的压缩,而不仅仅是 PHP 输出:)

  2. 是的,您可以将 zlib.output_compression 设置为数值 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 压缩级别使用 zlib.output_compression_level,默认为 -1,级别 6(默认值 -1,让服务器决定使用哪个级别)。但! PHP手册http://php.net/manual/en/function.ob-gzhandler.php说:

    You cannot use both ob_gzhandler() and zlib.output_compression. Also note that using zlib.output_compression is preferred over ob_gzhandler().

关于php - zlib.output_compression 和 output_buffering,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25363864/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com