Home  >  Q&A  >  body text

nginx configures gzip to compress css but not compress js

The nginx I use is 1.6. gzip is written in the configuration file. See below

gzip on;
gzip_min_length 1k;
gzip_buffers 16 64k;
gzip_http_version 1.1;
gzip_comp_level 9;
gzip_types text/plain application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
gzip_vary on;   

But I used the online testing tool http://gtmetrix.com/ to test. Only the css was compressed and the js was not compressed (the same is true for the domestic webkaka speed test). How strange.
I asked many people, but no one knows. Could it be due to my configuration? Thanks!

大家讲道理大家讲道理2737 days ago572

reply all(1)I'll reply

  • 天蓬老师

    天蓬老师2017-05-16 17:29:04

    ⊙﹏⊙bhan, adding application/javascript is OK. Why don’t I have this in the code I posted online? I searched for a long time!

    reply
    0
  • Cancelreply