我正在使用Codeigniter PHP框架和apache2
我在apache2中启用了Gzip和deflate mod,并显示了phpinfo()。当我运行Yslow时,它显示“使用gzip 压缩组件上的F级”
甚至我改变了Codeigniter的config.php
$config['compress_output'] = TRUE;
但没有效果。有什么我想念的。
答案 0 :(得分:2)
你应该为CSS,html,js启用mod_deflate。
例如:
<ifmodule deflate_module>
DeflateCompressionLevel 1
DeflateBufferSize 8096
DeflateMemLevel 8
DeflateWindowSize 8
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/xml
</ifmodule>
因为图片或视频已经过压缩,而且还需要花费大量时间来尝试压缩。 php.ini上还有一个压缩选项
也许有帮助...
答案 1 :(得分:1)
<IfModule mod_deflate.c>
<IfModule mod_setenvif.c>
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
</IfModule>
<IfModule mod_headers.c>
Header append Vary User-Agent env=!dont-vary
</IfModule>
<IfModule mod_filter.c>
AddOutputFilterByType DEFLATE text/css application/x-javascript text/x-component text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon
</IfModule>
</IfModule>