Service Worker Install Event
Which event in the Service Worker lifecycle is typically used to pre-cache essential assets for offline support?
- install
- fetch
- activate
- online
- load
Cache First Strategy
When a Service Worker employs a 'Cache First' strategy, which source does it check for a resource before making a network request?
- It checks the cache before the network
- It checks the network before the cache
- It loads from localStorage only
- It sends a request directly to the server
- It retrieves from IndexedDB
Service Worker Scope
If a Service Worker is registered at '/sw.js', which URL will it control?
- All pages under '/'
- Only '/sw.js'
- Only '/home'
- Every page on the domain, regardless of path
- Only pages under '/sw'
Network Falling-Back to Cache
What is the proper term for a strategy where the Service Worker tries the network first, then falls back to the cache if the network fails?
- Network First
- Cache Only
- Cache First
- Stale-while-revalidate
- Network Only
Caching Dynamic Content
Which strategy is best suited for API responses that must always be up to date but should also support offline use?
- Stale-while-revalidate
- Cache Only
- Cache First
- Cache then Network
- Precache Only
Service Worker Update Flow
After a Service Worker script changes and the new script is downloaded, which event occurs before the new worker takes control?
- activate
- install
- fetch
- message
- sync
Offline Fallback Page
How can you ensure users see a custom offline page when they lose connection while using your site?
- Serve a cached offline.html when fetch fails
- Redirect to index.html
- Store the offline page in sessionStorage
- Disable the Service Worker
- Update the manifest.json
Cache Storage API Usage
Which method is used to add assets to a named cache within a Service Worker?
- cache.addAll()
- cacheStore.putAll()
- caches.collect()
- storage.addCache()
- assets.cacheAll()
Cache Versioning and Clean-up
What is the best way to remove outdated caches in a Service Worker?
- Delete old cache names during the activate event
- Remove caches in the install event
- Use window.clearCache()
- Call caches.delete() from the fetch event
- Unregister the Service Worker
Handling POST Requests for Offline Support
Which technique can enable offline support for POST requests in PWAs using Service Workers?
- Background Sync
- Stale-while-revalidate
- Precache only
- Cache Only strategy
- Push API