fix: '날씨 불러오는 중'에서 두 번째로 다시 불러올 때부터 폰에 남은 빌드 파일을 새로 받아 덮고 서비스 워커를 걷어낸 뒤 다시 불러옴 — 1년 캐시된 파일이 깨져 새로고침해도 계속 멈추던 경우를 스스로 풂
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
fabf9b3910
commit
b8b5bcf31a
1 file changed
+14
-1
+14
-1
@@ -38,7 +38,20 @@
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('[boot] storage', 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) {
|
function note(msg) {
|
||||||
if (errs.length < 3) errs.push(String(msg).slice(0, 160))
|
if (errs.length < 3) errs.push(String(msg).slice(0, 160))
|
||||||
|
|||||||
Reference in new issue
Block a user