Recall & Review
beginner
What is a service worker in web development?
A service worker is a script that runs in the background of a web browser, separate from the web page. It helps manage caching, offline support, and background tasks like push notifications.
Click to reveal answer
beginner
How do service workers improve user experience in Svelte apps?
Service workers cache app files and data, so the app loads faster and works offline. This means users can keep using the app even without an internet connection.
Click to reveal answer
intermediate
Which lifecycle event is used to cache files when a service worker is installed?
The 'install' event is used to cache files. During this event, the service worker can open a cache and store important files for offline use.
Click to reveal answer
intermediate
What is the role of the 'fetch' event in a service worker?
The 'fetch' event intercepts network requests. The service worker can respond with cached files or fetch fresh data from the network, enabling offline support and faster loading.
Click to reveal answer
beginner
How can you register a service worker in a Svelte app?
You register a service worker by calling 'navigator.serviceWorker.register("/service-worker.js")' in your app's main script, usually inside a lifecycle hook or on page load.
Click to reveal answer
What does a service worker run separately from?
✗ Incorrect
Service workers run separately from the web page in the browser background.
Which event is used to cache files when a service worker starts?
✗ Incorrect
The 'install' event is where caching usually happens.
How does a service worker help when the user is offline?
✗ Incorrect
Service workers serve cached files to keep the app working offline.
Where do you usually register a service worker in a Svelte app?
✗ Incorrect
You register service workers in the main JavaScript or Svelte script.
What does the 'fetch' event in a service worker do?
✗ Incorrect
The 'fetch' event lets the service worker intercept network requests.
Explain how service workers enable offline support in a Svelte app.
Think about how the app can still work without internet.
You got /4 concepts.
Describe the steps to register and use a service worker in a Svelte project.
Focus on registration and lifecycle events.
You got /4 concepts.