为Django的NGINX服务器上的CSS和JS文件启用GZIP

时间:2016-05-08 17:34:02

标签: javascript css django nginx compression

x配置文件/etc/nginx/ngnix.conf并没有发现任何问题。仍然无法看到css和javascript Gzip压缩。我的NGINX.conf条目如下 -

    gzip on;
    gzip_disable "msie6";

    gzip_comp_level 6;
    gzip_min_length 1100;
    gzip_buffers 16 8k;
    gzip_proxied any;
    gzip_types text/plain text/css text/js text/xml text/javascript application/javascript application/x-javascript application/json application/xml application/xml+rss;

1 个答案:

答案 0 :(得分:6)

我认为你缺少gzip_vary on;,这就是为列出的gzip_types启用gzip压缩的原因

gzip on;
gzip_vary on;
gzip_proxied any;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;