Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

serviceWorker 坑 #57

Open
kangning1206 opened this issue Jul 31, 2020 · 0 comments
Open

serviceWorker 坑 #57

kangning1206 opened this issue Jul 31, 2020 · 0 comments

Comments

@kangning1206
Copy link
Owner

vue项目中启用了serviceWorker,离线缓存,但不清楚个别用户浏览器总是不能获取到最新项目版本代码,导致页面错误或显示缺陷,在找不到根源的情况下,决定卸载;

卸载 serviceWorker

navigator.serviceWorker.getRegistrations()
  .then(registrations => {
    registrations.forEach(registration => {
      registration.unregister()
    }) 
  })

不卸载,但清理缓存;

caches.keys().then(function(names) {
    for (let name of names)
        caches.delete(name);
});

浏览器缓存加载顺序: serviceWorker=>强制缓存=>协商缓存=> 无缓存 => 服务器;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant