技术&日志

vue打包上传服务器页面没有更新

nginx配置禁用缓存

location /myApp/ {
  root /www/webproject;
  try_files $uri @index;
}

location @index {
  root /www/webproject;
  add_header Cache-Control no-store;
  expires 0;
  try_files /crmwap/index.html =404;
}

index.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">

vue webpack 配置文件版本

build--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')
  }

相关资料

vue项目打包之浏览器存在缓存问题
vue项目如何让网页端浏览器不缓存自动更新

发表评论