由於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