Fetch API Streaming Response Sample

Available in Chrome 43+

This demo will search the first billion digits of PI for a substring you specify, and tell you the position at which it was found. It will do this without consuming a billion bytes of memory! That was impossible with XHR!

Furthermore, it won't even need to do text decoding and string comparison, as it will operate on the bytes directly. (XHR's pseudo-streaming mode, with an ever-growing responseText you could poll, was text-only.)

Finally, once it finds the substring, it will cancel the stream, preventing further network usage! Canceling a fetch was not previously possible. (It is not yet possible to cancel before the headers arrive; see slightlyoff/ServiceWorker#592 and linked issues.)