如何检查PHP是否启用了gzip压缩?
如何检查PHP是否启用了gzip压缩?,php,compression,gzip,Php,Compression,Gzip,(函数存在('ob\u gzhandler')和&ini\u get('zlib.output\u compression'))是否足够 我想检查主机是否在其中一个页面中提供压缩页面:)带有 <?php phpinfo(); ?> 您可以找到模块是否已加载 或 本网站 您可以检查是否启用了特定页面上的压缩 对于这些,您将看到压缩是否足够。对于PHP,它们会很好 但是,如果要将页面压缩回客户端,还需要检查它在apache中是否已启用(假设您使用apache,则需要mod_gzip
(函数存在('ob\u gzhandler')和&ini\u get('zlib.output\u compression'))
是否足够
我想检查主机是否在其中一个页面中提供压缩页面:)带有
<?php
phpinfo();
?>
您可以找到模块是否已加载
或
本网站
您可以检查是否启用了特定页面上的压缩
对于这些,您将看到压缩是否足够。对于PHP,它们会很好 但是,如果要将页面压缩回客户端,还需要检查它在apache中是否已启用(假设您使用apache,则需要mod_gzip.c或mod_deflate.c模块) 例如:
#httpd-l
(apache 2)
我还看到在过去提到需要实现.htaccess覆盖:
#compress all text & html:
AddOutputFilterByType DEFLATE text/html text/plain text/xml
# Or, compress certain file types by extension:
<Files *.html>
SetOutputFilter DEFLATE
</Files>
#压缩所有文本和html:
AddOutputFilterByType DEFLATE text/html text/plain text/xml
#或者,按扩展名压缩某些文件类型:
SetOutputFilter放气
您可以通过php以编程方式执行此操作:
if (count(array_intersect(['mod_deflate', 'mod_gzip'], apache_get_modules())) > 0) {
echo 'compression enabled';
}
这当然不是非常可靠,因为可能还有其他压缩模块…@Philipp我已经将其更改为工作模块。在谷歌上搜索
gzip压缩检查器)