1、 html缓存
<!-- 清除html缓存 -->
<meta http-equiv="pragram" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="expires" content="0" />
2、css缓存 (vue.config.js配置)
const version = new Date().getTime();
写法一:
// css相关配置
css: {
// 开启 CSS source maps,可以快速定位到css位置
sourceMap: false,
// 是否使用css分离插件 ExtractTextPlugin
extract: {
// 修改打包后css文件名 // css打包文件,添加时间戳
filename: `css/[name].${version}.css`,
chunkFilename: `css/[name].${version}.css`,
},
},
写法二:
chainWebpack: config => {
config.plugin('extract-css').tap(args => [{
filename: `static/css/[name].${version}.css`,
chunkFilename: `static/css/[name].${version}.css`
}])
}
3、js缓存(vue.config.js配置)
const version = new Date().getTime();
configureWebpack: (config) => {
// 输出重构 打包编译后的 文件名称 【模块名称.版本号.时间戳】
config.output.filename = `static/js/[name].${version}.js`;
config.output.chunkFilename = `static/js/[name].${version}.js`;
},
configureWebpack: { // webpack 配置
output: { // 输出重构 打包编译后的 文件名称 【模块名称.版本号.时间戳】
filename: `static/js/[name].${version}.js`,
chunkFilename: `static/js/[name].${version}.js`
},
},