是(function_exists('ob_gzhandler') && ini_get('zlib.output_compression'))
就够了吗?如何检查是否gzip压缩与支持PHP的?
我想检查主机所服务的网页:)
是(function_exists('ob_gzhandler') && ini_get('zlib.output_compression'))
就够了吗?如何检查是否gzip压缩与支持PHP的?
我想检查主机所服务的网页:)
对于PHP,他们会做得很好。但是,如果您将页面压缩回客户端,您还需要检查它是否在apache中启用(假设您使用apache,则需要mod_gzip.c或mod_deflate.c模块)。
例如: # httpd -l
(阿帕奇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>
随着
的一个内压缩的页面<?php
phpinfo();
?>
如果模块被加载
或
你可以找到本网站http://www.gidnetwork.com/tools/gzip-test.php
你可以检查某个页面上的压缩是否启用。
有了这些,你会看到,如果压缩足够你。
你可以从PHP编程方式做到这一点:
if (count(array_intersect(['mod_deflate', 'mod_gzip'], apache_get_modules())) > 0) {
echo 'compression enabled';
}
这当然不是超级可靠,因为可能有其他压缩模块...