CSS and Javascript files are not Gzipped in Nginx
I can't find a solution on how to enable gzip for css and javascript files for nginx. Html files are gzipped without a problem. Gzip was enabled by default. What could be the reason that html is gzipped but not css or js files? Thank you for your help.
Output from config:
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
typeshashmax_size 2048;
server_tokens off;
servernameshashbucketsize 64;
servernamein_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
#
Logging Settings
#
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
#
Gzip Settings
#
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzipcomplevel 2;
gzip_buffers 16 8k;
gziphttpversion 1.1;
gzip_types text/plain text/html text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
#
nginx-naxsi config
#
Uncomment it if you installed nginx-naxsi
#
include /etc/nginx/naxsi_core.rules;
#
nginx-passenger config
#
Uncomment it if you installed nginx-passenger
#
passenger_root /usr;
passenger_ruby /usr/bin/ruby;
#
Virtual Host Configs
#
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
5 Replies
this
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 2;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/html text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
For future reference, depending on the type of config, comments can also be in ; - // - - -- or in some cases ''