【发布时间】:2012-01-28 11:25:15
【问题描述】:
我的 apache Web 服务器管理员声称,该服务器支持 deflate gzip 压缩,因此向我显示环境变量 HTTP_ACCEPT_ENCODING gzip,deflate。
我知道有两种压缩方法。方法一,在 PHP 级别,使用ob_start('ob_gzhandler'),第二种方法是在服务器级别,使用.htaccess,里面有一些命令,比如这个
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css
<FilesMatch "\\.(js|css|html|htm|php|xml)$">
SetOutputFilter DEFLATE
</FilesMatch>
我使用page speed等工具检查这两种压缩方法
第一种方法适合我,但第二种方法不起作用。
我想使用服务器端压缩方法,我发现网上很多人都有像我这样的问题。
服务器管理员只是声称everything is ok from his point of view and gzip/deflate is active
我对@987654330@ 有其他问题,谷歌推荐网站管理员使用它。
就像压缩一样,.htaccess文件也有标准编码,比如这个
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 2 days"
</IfModule>
不幸的是,它不像压缩那样工作。 我们的 apache 服务器版本是 2.2.20。
我不知道如何向服务器管理员证明,服务器安装有问题。
也许这是这个版本的apache的一个错误。 我真的很困惑,特别是当我了解到世界上有一些人和我有完全相同的问题并且没有回复时。
【问题讨论】:
标签: php linux apache caching compression