1. 浏览器禁止缓存

<meta http-equiv="pragma" content="no-cache">
  <meta http-equiv="Cache-Control" content="no-cache, must-revalidate">
  <meta http-equiv="expires" content="0">

元信息解说:https://www.cnblogs.com/jesse131/p/5334311.html

2. webpack 打包js后面添加时间戳,清缓存

webpack.prod.conf.js

const  Version = new Date().getTime();
...
output: {
    path: config.build.assetsRoot,
    filename: utils.assetsPath('js/[name].[chunkhash].'+Version+'.js'),
    chunkFilename: utils.assetsPath('js/[id].[chunkhash].'+Version+'.js')
  },
...

3. vue-cli

vue.config.js   vue-cli打包的时候,内置会给js加上hashchunk,自动清缓存,

下面的配置不能生效,不要自己配了,直接使用内置

const Timestamp=new Date().getTime();
module.exports = {
    configureWebpack: {
    
        output: { // 输出重构  打包编译后的 文件名称  【模块名称.版本号.时间戳】
          filename: `[name].${version}.${Timestamp}.js`,
          chunkFilename: `[name].${version}.${Timestamp}.js`
        }
    },
}

 

相关文章:

  • 2022-01-17
  • 2021-10-17
  • 2022-12-23
  • 2021-09-29
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-19
猜你喜欢
  • 2022-01-05
  • 2021-12-02
  • 2022-01-26
  • 2021-12-21
  • 2021-08-08
  • 2022-02-07
相关资源
相似解决方案