NGINX gzip 不压缩 JavaScript 文件

标签 nginx

所有 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;

最佳答案

更改此行:

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;

请注意将 application/javascripttext/javascript 添加到您的 gzip 类型列表中。

答案 posted here 中还有更多详细信息以及更广泛的 gzip 类型列表。 .

关于NGINX gzip 不压缩 JavaScript 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23939722/

相关文章:

nginx - 在 Chef 部署的 Nginx 服务器中扩展 mime 类型

tomcat - Xwiki:无法从 URL [https://my.domain.com/bin/view/Main/] 中提取实体资源引用

docker - 如何在 Windows 上的 Docker 中启动 nginx

nginx - 如何使用 nginx 将服务器上的特定文件作为特定路径提供服务?

php - 404 未找到 nginx/1.10.3 (Ubuntu)

php - Nginx - 将包括 .php 在内的所有请求重定向到单个 PHP 脚本?

ruby-on-rails - 为什么 Nginx 一直返回 301?

Django、Nginx、Gunicorn 静态文件不工作

ubuntu - Nginx 非 www 无法在 Ubuntu 16.04 中工作和重定向

amazon-web-services - 如何通过入口 Controller 在 Kubernetes 中公开内部服务