【发布时间】:2012-08-18 15:25:43
【问题描述】:
我有一个想要优化的应用。将以下 gzip 配置添加到 Nginx 后,我仍然收到以下文件未压缩并且可以节省 400k 负载的错误。
Config:
# output compression saves bandwidth
gzip on;
gzip_http_version 1.1;
gzip_vary on;
gzip_comp_level 6;
gzip_proxied any;
gzip_types text/plain text/html text/css application/json application/javascript application/x-javascript text/javascript text/xml application/xml application/rss+xml application/atom+xml application/rdf+xml;
# make sure gzip does not lose large gzipped js or css files
# see http://blog.leetsoft.com/2007/7/25/nginx-gzip-ssl
gzip_buffers 16 8k;
# Disable gzip for certain browsers.
gzip_disable “MSIE [1-6].(?!.*SV1)”;
Files:
Compressing the following resources with gzip could reduce their transfer size by 445.6KiB (77% reduction).
Compressing https://cad.hcem.com/.../application-c58641bce5c2c94f380075bb5... could save 272.1KiB (73% reduction).
Compressing https://cad.hcem.com/.../application-99c35c4a0df5a19bfd5ed6938... could save 173.5KiB (84% reduction).
在我的配置中,我似乎已经为压缩打开了 javascript。我是否遗漏了一些不会将这些文件压缩到管道之外的东西?
【问题讨论】:
-
什么是未压缩文件的 Content-Type http 标头?
-
看起来我的剪切/粘贴被切断了。这些是 JS 文件,是贯穿资产管道的主要 application.js 文件。
-
这意味着他们应该获得与您的 gzip_types 匹配的 Content-Type。你确认确实是这样吗?我没有在您发布的配置中发现任何错误,它应该可以工作。如果问题是它提供的 Content-Type,那么下一个要看的地方是你的 /etc/nginx/mime.types
标签: ruby-on-rails-3 nginx compression gzip