开启gzip

第一种前端打包生成gz文件

const CompressionWebpackPlugin = require('compression-webpack-plugin')

javascript 复制代码
    configureWebpack: {
      output: {
      },
      plugins: [
        new CompressionWebpackPlugin({
          algorithm: 'gzip',
          test: new RegExp('\\.(' + ['js', 'css'].join('|') + ')$'),
          threshold: 10240,
          minRatio: 0.8
        })
      ]
    },

第二种nginx 开启gzip

http: {

#开启gzip

gzip ``on``;

#低于1kb的资源不压缩

gzip_min_length 1k;

#压缩级别1-9,越大压缩率越高,同时消耗cpu资源也越多,建议设置在5左右。

gzip_comp_level 5;

#需要压缩哪些响应类型的资源,多个空格隔开。不建议压缩图片.

gzip_types text/plain application/javascript application/x-javascript text/javascript text/xml text/css;

#配置禁用gzip条件,支持正则。此处表示ie6及以下不启用gzip(因为ie低版本不支持)

gzip_disable ``"MSIE [1-6]\."``;

#是否添加"Vary: Accept-Encoding"响应头

gzip_vary ``on``;

}

使用vue打包时gzip压缩的两种方案 - Python技术站

相关推荐
似的8354 小时前
一步一步学习使用FireMonkey动画() 使用TAnimator类创建动画
linux·学习·nginx
闪亮的路灯1 天前
威联通QTS使用自带web服务期代理前端(类似nginx)
前端·nginx·威联通
難釋懷2 天前
Nginx外置缓存-error_page
运维·nginx·缓存
怪味趣多2 天前
r创建动画。 . 使用TFloatAnimation通过改变图片的位置创建动车。 . 使用TPathAnimation创建路径动画。 ...
运维·nginx
七七powerful3 天前
为离线的bcliunx euler&龙晰 配置 yum源 nginx代理
nginx·yum·bclinux
AlbertS3 天前
Let‘s Encrypt 证书自动续期并自动应用到Nginx
运维·nginx·ssl·cerbot·renew·续期
Python私教3 天前
Godot 4 AnimatedSprite2D 实战:让待机与移动动画自动切换
nginx·游戏引擎·godot·动画·游戏开发
泡沫冰@3 天前
上章节中文件的讲解
前端·网络·nginx
難釋懷4 天前
Nginx内存缓存
nginx·缓存·junit
云计算磊哥@4 天前
运维开发宝典059-大型网站nginx服务器管理全集5
服务器·nginx·运维开发