umi项目禁用html缓存

umi项目打包后还是使用上一个版本,存在缓存

在项目config.ts或.umirc.ts 内写上metas配置:

 metas: [
    {
    
    
      httpEquiv: 'Cache-Control',
      content: 'no-cache',
    },
    {
    
    
      httpEquiv: 'Pragma',
      content: 'no-cache',
    },
    {
    
    
      httpEquiv: 'Expires',
      content: '0',
    },
  ],

打包后会在index.html中生成如下
在这里插入图片描述

后面发现这样还是会有缓存

在项目config.ts或.umirc.ts 配置hash:

hash:true

这样打包后会在js和css加上hash版本号,就不会有缓存了
在这里插入图片描述

おすすめ

転載: blog.csdn.net/weixin_47541876/article/details/124481312