当前位置:网站首页>vue项目 npm run build 打包项目防止浏览器缓存
vue项目 npm run build 打包项目防止浏览器缓存
2022-08-10 02:45:00 【船长在船上】
在vue.config.js配置
推荐方法1:
const Timestamp = new Date().getTime()
module.exports = {
......
configureWebpack: config => {
config.output.filename = `js/[name].${Timestamp}.js`
config.output.chunkFilename = `js/[name].${Timestamp}.js`
},
......
css: {
......
extract: {
filename: `css/[name].${Timestamp}.css`,
chunkFilename: `css/[name].${Timestamp}.css`
}
......
}
}
方法2:index.html页面添加
<meta http-equiv="Expires" content="0">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-control" content="no-cache">
<meta http-equiv="Cache" content="no-cache">
这样添加会导致了用户每次访问你的程序时都要重新请求服务器,所有的静态资源都无法用缓存了,浪费流量,网络压力变大。
边栏推荐
猜你喜欢
随机推荐
使用flink-sql写入mysql的时候,只指定插入的字段,但是会报错id字段错误,没有默认值,创
mock模拟,skip,skipif,mark分类
芯片加速器 Accelerator
[Red Team] ATT&CK - Self-starting - Self-starting mechanism using LSA authentication package
《天才基本法》:平行时空的第二次选择,小演员的表现意外出圈
从滑动标尺模型看企业网络安全能力评估与建设
实例043:作用域、类的方法与变量
一文教会你快速上手 Vim
PostgreSQL相关语法及指令示例
[Kali Security Penetration Testing Practice Course] Chapter 8 Web Penetration
如何让导电滑环信号更好
二维空间下的向量旋转
liunx PS1 设置
2022.8.8考试区域链接(district)题解
Error state based Kalman filter ESKF
Arrays类
what is a microcontroller or mcu
Example 046: Breaking the Cycle
2022.8.8 Exam written in memory (memory)
Little rookie Hebei Unicom induction training essay