最近在使用nginx對於前端的靜態文件作壓縮的時候,發現配置以後,js文件並無壓縮成功,以下是個人配置:
gzip on;
gzip_min_length 5k;
gzip_buffers 4 16k;
gzip_comp_level 4;
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;javascript
後來發現壓縮類型gzip_types中的application/x-javascript並非表明javascript,真正表明javascript的是:application/javascript,因此還須要在gzip_types中添加進去。即:php
gzip on;
gzip_min_length 5k;
gzip_buffers 4 16k;
gzip_comp_level 4;
gzip_types application/javascript text/plain application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
gzip_vary on;css