gpt4 book ai didi

PHP 禁用 zlib.output_compression

转载 作者:行者123 更新时间:2023-12-03 22:46:48 26 4
gpt4 key购买 nike

我的网站有 zlib.output_compression设置为 On在ini文件中,它会在发送到浏览器时压缩所有响应。

如何仅对二进制文件、PDF 文件和 excel 文件禁用压缩,以便在下载文件时正确输出到浏览器?

最佳答案

在您的服务器中使用 .conf 文件,将压缩限制为正确的 MIME 类型

例如在 /etc/httpd/conf.d/enable_mod_deflate.conf :

# mod_deflate configuration
<IfModule mod_deflate.c>
# Restrict compression to these MIME types
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xml+rss
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE image/png
AddOutputFilterByType DEFLATE image/gif
AddOutputFilterByType DEFLATE image/jpeg

# Level of compression (Highest 9 - Lowest 1)
DeflateCompressionLevel 9

# Netscape 4.x has some problems.
BrowserMatch ^Mozilla/4 gzip-only-text/html

# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip

# MSIE masquerades as Netscape, but it is fine
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html

<IfModule mod_headers.c>
# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary
</IfModule>
</IfModule>

不要忘记重新启动您的服务器
sudo service httpd restart

关于PHP 禁用 zlib.output_compression,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29015454/

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