A partial archive of discourse.wicg.io as of Saturday February 24, 2024.

Proposal: Background fetch

Jake_Archibald
2017-02-09

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.

Goals

  • 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

Status

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.

cwilso
2017-02-10

Based on positive feedback in blink-dev thread, this has been moved to a WICG repo: https://github.com/WICG/background-fetch.

Jake_Archibald
2017-02-21

@cwilso I’ve added a stub spec. Can you mirror the repo to github pages? I don’t have access to settings so I can’t do this myself.

cwilso
2017-02-22
  1. Added default gh-pages branch
  2. Removed master
  3. Made you an admin.
tabatkins
2017-02-22

@cwilso :confused: Using gh-pages is no longer recommended (and looks to no longer be available for new repos at all). There’s a setting for turning on GitHub Pages, with option to have it expose either the root of the repo or the /docs folder.

I guess Jake can do that now, and switch the branch back to being named “master”.

cwilso
2017-02-22

gah, sorry. that’s what happens when I get jetlagged and behind.