淺談微信頁面入口文件被緩存解決方案


由於js文件有hash,用於防止版本更新之后還訪問到老的文件。但是昨天發現部分用戶訪問系統白屏,懷疑是微信緩存了index.html入口文件,導致還訪問老版本的js文件。由於老版本被刪掉,所以白屏。

處理方法:

1.cdn上將index.html的文件緩存設置為0

2.框架上進行修改

<!-- cache control: no cache -->
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />

3.nginx涉資不緩存

location / {
  root  /mnt/dat1/test/tes-app;
  index index.html index.htm;
  try_files $uri $uri/ /index.html;
  #### kill cache
  add_header Last-Modified $date_gmt;
  add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
  if_modified_since off;
  expires off;
  etag off;
}
 
location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|js)$ {
  root  /mnt/dat1/test/tes-app;
  access_log off;
  expires 30d;
} 

 

設置完成之后不緩存:

 

 

 

 

 

參考文件:https://www.jb51.net/article/148249.htm

 


免責聲明!

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



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