我正在研究我的网站速度优化。我在使用 gzip 压缩时遇到问题。我把代码放在.htaccess
文件里,上传到网上,它不起作用。当我检查这个工具http://www.gidnetwork.com/tools/gzip-test.php它说page content is not compressed
。我也用 gtmetrix.com 检查它,但仍然没有运气。
这是我放入.htaccess
文件中的代码:
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
</IfModule>
我也试过没有<IfModule mod_deflate.c></IfModule>
:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
在我的 htaccess 中也试过这个方法:
<files *.html>
SetOutputFilter DEFLATE
</files>
仍然没有运气。难道我做错了什么?如果可以的话请帮忙!