NGINX gzip不压缩JavaScript文件(NGINX gzip not compressing JavaScript files)

编程入门 行业动态 更新时间:2024-10-27 10:20:09
NGINX gzip不压缩JavaScript文件(NGINX gzip not compressing JavaScript files)

所有的JavaScript文件都没有被nginx gzip压缩。

CSS文件正在运行。

在我的nginx.conf我有以下几行:

gzip on; gzip_disable "MSIE [1-6]\.(?!.*SV1)"; gzip_proxied any; gzip_buffers 16 8k; gzip_types text/plain application/x-javascript text/xml text/css; gzip_vary on;

All JavaScript files are not compressed by nginx gzip.

CSS files are working.

In my nginx.conf I have the following lines:

gzip on; gzip_disable "MSIE [1-6]\.(?!.*SV1)"; gzip_proxied any; gzip_buffers 16 8k; gzip_types text/plain application/x-javascript text/xml text/css; gzip_vary on;

最满意答案

更改此行:

gzip_types text/plain application/x-javascript text/xml text/css;

为此:

gzip_types text/plain application/javascript application/x-javascript text/javascript text/xml text/css;

请注意在您的gzip类型列表中添加了application/javascript和text/javascript 。

在这里发布的答案中还有更多细节和更广泛的gzip类型列表。

Change this line:

gzip_types text/plain application/x-javascript text/xml text/css;

To be this:

gzip_types text/plain application/javascript application/x-javascript text/javascript text/xml text/css;

Note the addition of application/javascript and text/javascript to your list of gzip types.

There are also more details—and a more expansive list of gzip types—in the answer posted here.

更多推荐

本文发布于:2023-08-07 22:30:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1466168.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件   gzip   NGINX   JavaScript   files

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!