Nginx静态文件压缩和代码压缩配置教程

2022-06-04T16:37:00

nginx静态资源动态压缩

nginx开启gzip压缩

server {
        listen       80;
        listen  [::]:80;
        server_name  localhost;
        server_tokens off;

        # 开启gzip压缩
        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 application/css text/css application/xml text/javascript application/javascript application/x-javascript;
        
        #szxblog 前端
        location /jxbp {           
             alias  /usr/local/szxblog;
             index index.html;
             try_files $uri $uri/ /dist/index.html;
        }
 }      

然后重启

nginx:nginx -s reload
当前页面是本站的「Baidu MIP」版。发表评论请点击:完整版 »