JavaScript · Senior · Question 14 of 75
What can a Service Worker do?
- ✓Correct answer: Intercept the page's network requests and respond from cache, working offline
- 2Run the page's JavaScript faster by compiling it to WebAssembly
- 3Access the DOM of all open tabs of the same site
Explanation
A Service Worker is a proxy between the page and the network with its own lifecycle (install, activate, fetch). PWAs are built on it: caching strategies (cache-first, network-first, stale-while-revalidate), push notifications, background sync. It works only over HTTPS and can't see the DOM.