我使用的是Codeigniter的PHP框架和apache2。
我已經在apache2中啓用了Gzip和def def mod,並且顯示了phpinfo()。當我運行Yslow時,它顯示「壓縮部件上的F級,使用gzip」。
即使我改笨
$config['compress_output'] = TRUE;
在Codeigniter中使用Gzip/Deflate以獲得更好的性能
的config.php文件,但沒有效果。我錯過了什麼?
我使用的是Codeigniter的PHP框架和apache2。
我已經在apache2中啓用了Gzip和def def mod,並且顯示了phpinfo()。當我運行Yslow時,它顯示「壓縮部件上的F級,使用gzip」。
即使我改笨
$config['compress_output'] = TRUE;
在Codeigniter中使用Gzip/Deflate以獲得更好的性能
的config.php文件,但沒有效果。我錯過了什麼?
您應該爲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中
也許它可以幫助一個壓縮選項...
很棒!謝謝 – damko 2013-03-22 13:07:20
這個文件我放在哪裏 – user307709 2015-11-17 06:00:26
<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>
同樣的問題? http://stackoverflow.com/questions/973969/yslow-gives-f-grade-to-files-compressed-with-mod-deflate – ajreal 2010-11-11 07:46:22
上述問題是由於代理。在我的情況下,我沒有任何代理。 – 2010-11-12 06:05:04