Service Workers: Caching Strategies u0026 Offline Support Quiz Quiz

  1. Service Worker Install Event

    Which event in the Service Worker lifecycle is typically used to pre-cache essential assets for offline support?

    1. install
    2. fetch
    3. activate
    4. online
    5. load
  2. 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?

    1. It checks the cache before the network
    2. It checks the network before the cache
    3. It loads from localStorage only
    4. It sends a request directly to the server
    5. It retrieves from IndexedDB
  3. Service Worker Scope

    If a Service Worker is registered at '/sw.js', which URL will it control?

    1. All pages under '/'
    2. Only '/sw.js'
    3. Only '/home'
    4. Every page on the domain, regardless of path
    5. Only pages under '/sw'
  4. 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?

    1. Network First
    2. Cache Only
    3. Cache First
    4. Stale-while-revalidate
    5. Network Only
  5. Caching Dynamic Content

    Which strategy is best suited for API responses that must always be up to date but should also support offline use?

    1. Stale-while-revalidate
    2. Cache Only
    3. Cache First
    4. Cache then Network
    5. Precache Only
  6. 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?

    1. activate
    2. install
    3. fetch
    4. message
    5. sync
  7. Offline Fallback Page

    How can you ensure users see a custom offline page when they lose connection while using your site?

    1. Serve a cached offline.html when fetch fails
    2. Redirect to index.html
    3. Store the offline page in sessionStorage
    4. Disable the Service Worker
    5. Update the manifest.json
  8. Cache Storage API Usage

    Which method is used to add assets to a named cache within a Service Worker?

    1. cache.addAll()
    2. cacheStore.putAll()
    3. caches.collect()
    4. storage.addCache()
    5. assets.cacheAll()
  9. Cache Versioning and Clean-up

    What is the best way to remove outdated caches in a Service Worker?

    1. Delete old cache names during the activate event
    2. Remove caches in the install event
    3. Use window.clearCache()
    4. Call caches.delete() from the fetch event
    5. Unregister the Service Worker
  10. Handling POST Requests for Offline Support

    Which technique can enable offline support for POST requests in PWAs using Service Workers?

    1. Background Sync
    2. Stale-while-revalidate
    3. Precache only
    4. Cache Only strategy
    5. Push API