The service worker is capable of fetching and caching assets, the size of which is restricted only by origin storage. However, if the user navigates away from the site or closes the browser, the service worker is likely to be killed. This can happen even if there's a pending promise passed to
extendableEvent.waitUntil, if it hasn't resolved within a few minutes the browser may consider it an abuse of service worker and kill the process.
This makes it difficult to download and cache large assets such as podcasts and movies, and upload video and images. Even if the service worker isn't killed, having to keep the service worker and therefore the browser in memory during this potentially long operation is wasteful.
- Enable background-download/upload of multiple resources
- Allow the OS to handle the fetch, so the browser doesn't need to continue running
- Allow the OS to show UI to indicate the progress of the fetch, and perhaps allow the user to pause/abort
- Allow the OS to deal with poor connectivity by pausing/resuming the download/upload (may be tricky with uploads, as ranged uploads aren't a thing)
- Allow the app to react to success/failure of the fetch, perhaps by showing a notification
There's an explainer at https://github.com/jakearchibald/background-fetch, along with a collection of issues by members from multiple browser vendors. I'm going to rewrite the explainer soon, incorporating the feedback so far.
There's an intent to implement for Chromium. This will help guide the design of the spec and API. We also plan to conduct an origin trial to assess API usability and make changes as a result.