我正在为我的网站加速优化工作。我遇到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>
仍然没有运气。难道我做错了什么?如果可以,请帮忙!
答案 0 :(得分:0)
对于Gzipping行为你的资产,试试这个。
<FilesMatch "\.(html|php|htm|xml|txt|xsl)$">
<IfModule mod_expires.c>
Header set Cache-Control "max-age=7200, must-revalidate"
Header append Vary Accept-Encoding
Header append Accept-Encoding "gzip"
</IfModule>
</FilesMatch>