1

我有一个想要优化的应用程序。将以下 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 进行压缩。我是否遗漏了一些不会将这些文件压缩到管道之外的东西?

4

1 回答 1

0

#在长线前面gzip_types放一个

并添加

gzip_types
    # text/html is always compressed by HttpGzipModule
    text/css 
    text/javascript
    text/xml
    text/plain
    text/x-component
    application/javascript
    application/x-javascript
    application/json
    application/xml
    application/rss+xml
    font/truetype
    font/opentype
    application/vnd.ms-fontobject
    image/svg+xml;
于 2012-09-16T02:39:05.337 回答