diff --git a/frontend/index.html b/frontend/index.html index 51e9792..a7c69a8 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -38,7 +38,20 @@ } catch (e) { console.error('[boot] storage', e) } - location.reload() + if (n < 1) return location.reload() + // 두 번째부터는 폰에 남은 빌드 파일(1년 캐시)이 깨졌을 수 있어 새로 받아 덮고, 서비스 워커도 걷어낸 뒤 다시 불러온다 + var files = [].map.call(document.querySelectorAll('script[src^="/"],link[rel=stylesheet][href^="/"],link[rel=modulepreload][href^="/"]'), function (el) { + return fetch(el.src || el.href, { cache: 'reload' }).catch(function (e) { + console.error('[boot] refetch', e) + }) + }) + var sw = navigator.serviceWorker ? navigator.serviceWorker.getRegistrations().then(function (rs) { + return Promise.all(rs.map(function (r) { return r.unregister() })) + }) : null + Promise.all(files.concat(sw ? [sw] : [])).then(function () { location.reload() }, function (e) { + console.error('[boot] cleanup', e) + location.reload() + }) } function note(msg) { if (errs.length < 3) errs.push(String(msg).slice(0, 160))