vue前端打包部署缓存问题

113 阅读1分钟

1、在项目中配置

(1)修改打包的版本号(package.json)

(2) 在项目的入口文件main.js中做版本的比对

2、修改打包的webpack配置配置 增加打包后静态文件的时间戳

3、nginx 配置,让index.html不缓存**(重要)**

location = /index.html {
    add_header Cache-Control "no-cache, no-store";
}

也有人说在入口文件index.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">