search

Home  >  Q&A  >  body text

After nginx enables gzip compression, the file size does not change.

The current situation is as shown in the figure. The size does not change after turning on gzip. Solution

Supplement nginx.conf

gzip  on;
gzip_comp_level 6;
gzip_min_length 10k;
gzip_buffers 16 8k;
gzip_proxied any;
gzip_types    text/plain application/javascript application/x-javascript application/json text/javascript text/xml

text/css;

巴扎黑巴扎黑2756 days ago472

reply all(1)I'll reply

  • 某草草

    某草草2017-05-16 17:19:20

    ngnixgzipThere are two key values ​​in the configuration:

    gzip_min_length: Minimum compression length
    Only the compressed content exceeding this length will be compressed, otherwise it will be output directly

    gzip_types: Compressed content typesgzip_types:压缩内容类型
    只有列出来的内容类型才会被压缩,其他类型的内容不会被压缩,类型指的是MIME类型。
    如需要压缩JS文件需配置gzip_types text/javascriptOnly the listed content types will be compressed, other types of content will not be compressed, the type refers to the MIME type.

    If you need to compress JS files, you need to configure gzip_types text/javascript🎜

    reply
    0
  • Cancelreply