EDIT1
It does not compress application/javascript
, but comresses text/html
whille text/html
is not listed in gzip_types
:
actually adding/remoing gzip on;
directive to the config does not have an effect.
You can also try testing on static URLs, and Nginx will return Content-Encoding: gzip
when configured properly:
location ~ ^/test.js$ {
gzip_types application/javascript;
gzip on;
default_type application/javascript;
return 200 "/***** hello *****/";
}
$ curl --compressed -kIX GET https://example.com/test.js
HTTP/1.1 200 OK
Server: nginx
Date: Fri, 01 Dec 2021 00:00:00 GMT
Content-Type: application/javascript; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Content-Encoding: gzip
CodePudding user response:
It is not Nginx, it is Google Chrome browser, pressing F5 does not actually reload the javascript (if Disable Cache is not checked).
Uncomment this in your /etc/nginx/nginx.conf
:
gzip on;
gzip_disable "msie6";
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml rss text/javascript;