zoukankan      html  css  js  c++  java
  • 清缓存的两种方法:webpack清缓存

    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`
            }
        },
    }
  • 相关阅读:
    数据库是什么以及用来干嘛
    10.3
    10.2
    12.7
    12.5
    12.4
    12.3
    12.2
    12.1JOptionPane
    11.30eclipse常用快捷键
  • 原文地址:https://www.cnblogs.com/mmzuo-798/p/13685515.html
Copyright © 2011-2022 走看看