Skip to content

Instantly share code, notes, and snippets.

@annevk
Created June 29, 2015 08:37
Show Gist options
  • Save annevk/722491359ba366dd81aa to your computer and use it in GitHub Desktop.
Save annevk/722491359ba366dd81aa to your computer and use it in GitHub Desktop.
Basic fetch flow
Drastic simplification of the browser networking model.
API (<img>, <script>, XMLHttpRequest, fetch(), etc.)
Creates a request with various settings
Invokes Fetch with that request
Uses the returned response in various ways.
Fetch (takes a request, returns a response)
If scheme is not http/https, follow scheme-specific rules to create a response.
If there's a service worker (and this invocation of Fetch did not come from a service worker), invoke Service worker.
If that doesn't result in a response, use HTTP cache.
If that doesn't result in a response, use network.
Return response.
Service worker (takes a request, returns null or a response)
Can do anything it likes to get to a response, including using an API such as `fetch()`.
Return null or response.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment