webpack打包gz文件,nginx开启gzip压缩

wepback配置
webpack4配合"compression-webpack-plugin": "^6.1.2"打包压缩gz

chain.plugin("compression").use(
        new CompressionPlugin({
          test: /\.js$|\.html$|\.css$/,
          threshold: 10240, // 超过10KB的压缩
          deleteOriginalAssets: false,// 保留源文件
        })
      )

上传文件到服务器
nginx配置

location /h5/ {
		gzip on;	// 动态压缩,如果没有gz文件再压缩
		gzip_static on;// 优先返回静态gz文件
		gzip_http_version 1.1;
		gzip_proxied expired no-cache no-store private auth;
		gzip_vary on;
		gzip_types text/plain application/javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
        add_header Cache-Control no-store;
        index  index.html;
        }

相关推荐

  1. webpack打包gz文件nginx开启gzip压缩

    2024-06-19 00:08:04       6 阅读
  2. nginx压缩文件gzip配置如何实现

    2024-06-19 00:08:04       14 阅读
  3. Linux-解压缩文件命令(gzip、zip、unzip、tar、jar)

    2024-06-19 00:08:04       10 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-06-19 00:08:04       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-06-19 00:08:04       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-06-19 00:08:04       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-06-19 00:08:04       18 阅读

热门阅读

  1. 如何构建构建一个AI驱动的通用爬虫

    2024-06-19 00:08:04       8 阅读
  2. Shell中执行.sh文件的常见方式

    2024-06-19 00:08:04       8 阅读
  3. 平移矩阵中的数学思考

    2024-06-19 00:08:04       8 阅读
  4. Spring Cloud Gateway 概述与基本配置(上)

    2024-06-19 00:08:04       7 阅读
  5. 从零学习es8

    2024-06-19 00:08:04       6 阅读