Skip to content
This repository has been archived by the owner on Jul 15, 2022. It is now read-only.

Fix API versioning #59

Merged
merged 1 commit into from Nov 4, 2020
Merged

Fix API versioning #59

merged 1 commit into from Nov 4, 2020

Conversation

mu-hun
Copy link
Owner

@mu-hun mu-hun commented Nov 4, 2020

resolve #17

install 이벤트에서 초기 버전을 설정하고, fetch에서 버전을 갱신하는 걸로 해결했습니다.

event.waitUntill 내부의 .catch 프로미스 체인 제거

프로미스 결과에 따라 event.waitUntill의 행동이 달라지는 것 같아 지웠습니다.

The ExtendableEvent.waitUntil() method tells the event dispatcher that work is ongoing. It can also be used to detect whether that work was successful.

ExtendableEvent.waitUntil() - Web APIs | MDN

ExtendableEvent.respondWith 내부의 오류의 경우 서비스 워커 콘솔이나, 네트워크 패널에서 조사가 가능하므로 지웠습니다.

둘다 예제를 그래로 가져오면서 console.log를 쓴 실수도 있었습니다. 😅

@mu-hun mu-hun merged commit 6f5f2fc into master Nov 4, 2020
@mu-hun mu-hun deleted the service-worker/fix-api-versioning branch November 4, 2020 03:13
Comment on lines +49 to +64
addCache(getCacheVersion(), API_URL)
])
)
})

self.addEventListener('fetch', evt => {
if (evt.request.url === API_URL) {
const currentAPI = getCacheVersion()
const cacheWhitelist = [CACHE_NAME, currentAPI]

evt.waitUntil(
caches.has(currentAPI).then(cache => {
if (!cache) {
return Promise.all([
addCache(currentAPI, API_URL),
cleanOldCache(cacheWhitelist)
Copy link
Owner Author

@mu-hun mu-hun Nov 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

install 이벤트에서 초기 버전을 설정하고, fetch에서 버전을 갱신합니다.

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

Successfully merging this pull request may close these issues.

캐싱된 학식 데이터 갱신이 안 이루어지고 있음
1 participant