GoogleChrome/samples — pull request #39 by jeffposnick (2014-10-29 17:17:38+00:00)
Title: Initial cut of the prefetch sample.

@kenjibaheux @jakearchibald @slightlyoff

Here's my initial attempt at the prefetch SW sample, closing #29. It could use some additional comments/explanatory text, but I wanted to get some feedback on the actual code.

It uses the native Cache API, currently only available in the latest Chrome Canary build. (Woo! No polyfills!) Since `cache.addAll()` isn't yet implemented natively, it performs multiple `fetch()` + `cache.put()` operations.

You can theoretically see a live demo of this code at https://rawgit.com/jeffposnick/samples/sw-prefetch/service-worker/prefetch/index.html but I'm in the process of figuring out why it doesn't work from there (`TypeError: Failed to fetch` for all `fetch()` requests), while it does work when accessed via http://localhost:8000.