일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
- peerdependencies
- 진행기록
- 올림픽 통계 서비스 최적화
- version management
- 딥다이브
- mixin pattern
- 브라우저의 렌더링 과정
- 블로그 서비스 최적화
- Babel과 Webpack
- 학습내용정리
- unique identifiers
- middleware pattern
- 이미지 갤러리 최적화
- 새 코드 받아오기
- js pattern
- 프로그래머스
- 커리어
- 자바스크립트
- package management
- const
- pr review
- DOM
- 자바스크립트 딥다이브
- 모던 자바스크립트 Deep Dive
- js pattern
- 이벤트
- 프론트엔드 성능 최적화 가이드
- 제너레이터와 async/await
- 스코프
- 자바스크립트 패턴
- Today
- Total
Dev Blog
Service worker 본문
What is Service Worker:
A service worker is a script that runs independently in the browser background. On the user side, it can intercept its network requests and decide what to load (fetch).
Service workers mainly serve features like background sync, push notifications and they are commonly used for’offline first’ applications, giving the developers the opportunity to take complete control over the user experience.
The service worker life cycle:
The service worker lifecycle is completely separate from the web page. It’s a programmable network proxy, which is terminated when it’s not used and restarted when it’s next needed. Service Workers heavily rely on the use of Javascript Promises.
During installation, the service worker can cache some static assets like web pages. If the browser cache the files successfully, the service worker gets installed.
Afterward, the worker needs to be activated. During activation the service worker can manage and decide what to happen to the old caches, typically they are being deleted and replaced with the new versions.
Lastly, after activation, the service worker takes control over all pages in his scope, without the page which initially registered the service worker, which needs to be refreshed. The service worker is smart in terms of memory usage and will be terminated if there is nothing to fetch and there are no message events occurring.
Service Worker can’t:
- Access the Parent Object
- Access the Window Object
- Access the Document Object
- Access the DOM
However, the Service Worker can:
- Cache Assets & API calls
- Manage Push Notifications
- Control the Network Traffic
- Store the Application Cache
Common use cases:
- Offline-optimized experience
- Sending Push Notifications
- Background sync
Source from: https://www.geeksforgeeks.org/service-workers-in-javascript/
'Development Notes > Terminology and Concepts' 카테고리의 다른 글
dependencies version in package.json (0) | 2021.10.16 |
---|---|
What is JSON File ? (0) | 2021.09.09 |
CDN (0) | 2021.08.01 |
PWA (0) | 2021.08.01 |
SPA - CSR/SSR/SSG (0) | 2021.08.01 |