vue項目,代碼部署之后,如何解決瀏覽器存在緩存問題


1.在index.html頭部添加如下代碼:

<meta http-equiv="pragram" content="no-cache">
<meta http-equiv="cache-control" content="no-cache, no-store, must-revalidate">

 

2.在vue.config.js中添加如下代碼:

const Timestamp = new Date().getTime();
module.exports = {
  configureWebpack: { // webpack 配置
    output: { // 輸出重構 打包編譯后的 文件名稱 【模塊名稱.版本號.時間戳】
      filename: `static/js/[name].${process.env.VUE_APP_Version}.${Timestamp}.js`,
      chunkFilename: `static/js/[name].${process.env.VUE_APP_Version}.${Timestamp}.js`
    },
  },
...
}

 

3.在nginx.conf頁面添加如下代碼:

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

 

https://blog.csdn.net/bamboozjy/article/details/111195022


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM