在Magento的NGINX服务器上为CSS和JS文件启用GZIP [英] Enable GZIP for CSS and JS files on NGINX server for Magento
问题描述
我需要在Nginx服务器上启用gzip压缩.正如我从firefox firebug NET工具中观察到的那样,我发现html文件是gzip压缩的.但不是javascript文件和CSS文件.
I need to enable gzip compression on nginx server. As I have observed from firfox firebug NET tools, I have found that html file are gzip compressed. But Not the javascript files and CSS files.
我已经检查了 Mime.types 和nginx配置文件/etc/nginx/ngnix.conf ,但没有发现任何问题. 仍然看不到CSS和javascript Gzip压缩. 我的NGINX.conf条目如下
I have already check Mime.types and nginx configuration file /etc/nginx/ngnix.conf and not found any issue. still not able to see the css and javascript Gzip Compression. My NGINX.conf entries are as below
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
推荐答案
这是我目前在生产环境中使用的有效配置.
This is an working config that I currently use in production.
gzip on;
gzip_disable "msie6";
gzip_comp_level 6;
gzip_min_length 1100;
gzip_buffers 16 8k;
gzip_proxied any;
gzip_types
text/plain
text/css
text/js
text/xml
text/javascript
application/javascript
application/json
application/xml
application/rss+xml
image/svg+xml;
此配置已通过tools.pingdom.com进行了测试.
This config was tested via tools.pingdom.com.
这篇关于在Magento的NGINX服务器上为CSS和JS文件启用GZIP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!