
060 - 프로그레시브 웹 앱
하면 새로운 캐시를 생성하고 반환합니다.
caches
.
open은 프로미스로 래핑된
캐시 객체를 반환합니다. 이후 then문을 사용해 캐시 객체를 변수로 받아
들이는 함수로 전달합니다.
마지막으로 할 일은
cache
.
add
('/index
-
offline
.
html' )
을 호출하여 파일을 가져
오고 "/
index
-
offline
.
html"
키와 함께 캐시에 저장하는 것입니다.
앞선 예제 코드는 연속된 프로미스 묶음입니다. 이를 의사 코드
(pseudocode)
로
바꾸면 다음과 같습니다.
If an install event is detected
,
don
’
t declare it a success until
:
You successfully open the cache
then
You successfully fetch the file and store it in the cache
If any of these steps failed
,
abort the service worker installation
.
install
이벤트가 발생한 후, 캐싱이 성공적으로 완료 될 때까지 그 어느 것이
라도 멈추면 서비스 워커가 설치되지 않습니다. 다시 말해, 활성화된 서비스 워커
가 있다면,
install
이벤트가 성공적으로 완료되었다는 것을 의미합니다. 이는
index ...