实现目标: 不需要手动清除浏览器缓存,点击浏览器刷新按钮或关闭浏览器重新打开 就可更新网站
- nginx 文件配置
主要添加Cache-Control "no-cache, no-store"
location / {
add header Cache-Control "no-cache, no-store".
root E:\xxxx;
index index.html index.htm;
}
- vue.config.js
filenameHashing 配置为true(默认为true),如果关闭,可以添加时间戳替代
router 路由懒加载的,添加分割的js 文件名
{
path: 'xxx',
name: 'xxx',
component: () => import(/* webpackChunkName: 'home' */ '@/views/xxx.vue'),
meta: { title: 'xxx' }
}