我正在尝试针对速度优化网站,并且我已使用以下代码段在htaccess文件中启用了mod_deflate。
<IfModule mod_deflate.c>
# Compress HTML, CSS, JavaScript, Text, XML and fonts
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE application/x-font
AddOutputFilterByType DEFLATE application/x-font-opentype
AddOutputFilterByType DEFLATE application/x-font-otf
AddOutputFilterByType DEFLATE application/x-font-truetype
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/css
AddOutputFilterByType DEFLATE font/opentype
AddOutputFilterByType DEFLATE font/otf
AddOutputFilterByType DEFLATE font/ttf
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE image/x-icon
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/xml
# Remove browser bugs (only needed for really old browsers)
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
Header append Vary User-Agent
</IfModule>
但是当我通过gtmetrix运行速度测试时,它告诉我一些文件还没有被gzip压缩。
http://example.com/themes/default/assets/js/jquery.themepunch.tools.min.js
http://example.com/themes/default/assets/js/jquery.js
http://example.com/themes/default/assets/js/jquery.themepunch.revolution.min.js
http://example.com/assets/js/bootstrap.min.js
http://example.com/assets/plugins/bootstrap-select/js/bootstrap-select.min.js
http://example.com/assets/plugins/bx-slider/jquery.bxslider.min.js
http://example.com/assets/plugins/bootstrap-touchspin/js/jquery.bootstrap-touchspin.min.js
http://example.com/assets/plugins/bootstrap-touchspin/css/jquery.bootstrap-touchspin.min.css
http://example.com/themes/default/assets/css/custom-2.css
对于mod_deflate,我不太了解。上面的部分是application
文件夹吗?我应该添加一个新的部分深入到子文件夹中。看起来这个文件可能会变得相当大
答案 0 :(得分:0)
这直接导致我的服务器出现问题。因为我的服务器使用了nginx,所以需要在nginx配置文件中设置所有缓存命令。