/
githubmirror
/
material-ui
Обзор
Документация
Войти
/
githubmirror
/
material-ui
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
v7.3.0
docs/src/sw.js
22 строки
964 B
Andrew Cherniavskii
[website] Add no-op service worker to fix stale cache issue (#37607)
03 июл 2023, 11:44
Не верифицирован
03 июл 2023, 11:44
cdf8dab
Код
Авторство
О чём код?
/* eslint-env serviceworker */ // https://github.com/airbnb/javascript/issues/1632 /* eslint-disable no-restricted-globals */ // See https://developer.chrome.com/docs/workbox/remove-buggy-service-workers/ self.addEventListener('install', () => { // Skip over the "waiting" lifecycle state, to ensure that our // new service worker is activated immediately, even if there's // another tab open controlled by our older service worker code. self.skipWaiting(); }); self.addEventListener('message', () => { // Optional: Get a list of all the current open windows/tabs under // our service worker's control, and force them to reload. // This can "unbreak" any open windows/tabs as soon as the new // service worker activates, rather than users having to manually reload. self.clients.matchAll({ type: 'window' }).then((windowClients) => { windowClients.forEach((windowClient) => { windowClient.navigate(windowClient.url); }); }); });