Vue版本更新清除浏览器缓存

时间:2022-07-24
本文章向大家介绍Vue版本更新清除浏览器缓存,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

修改build/webpack.prod.conf.js路径里的文件

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

 new HtmlWebpackPlugin({
      filename: process.env.NODE_ENV === 'testing' ?
        'index.html' :
        config.build.index,
      template: 'index.html',
      inject: true,
      hash: version,
      minify: {
        removeComments: true,
        collapseWhitespace: true,
        removeAttributeQuotes: true
        // more options:
        // https://github.com/kangax/html-minifier#options-quick-reference
      },
      // necessary to consistently work with multiple chunks via CommonsChunkPlugin
      chunksSortMode: 'dependency'
    }),

index.html页面

 <meta http-equiv="pragram" content="no-cache">
 <meta http-equiv="cache-control" content="no-cache, no-store, must-revalidate">
 <meta name="viewport" content="width=device-width,initial-scale=1.0">