Last active
August 29, 2015 14:04
-
-
Save wanderview/86a39a886d8653c4a208 to your computer and use it in GitHub Desktop.
ServiceWorker Cache Gecko Data Flows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Example uses of a ServiceWorker Cache to discuss how data flows | |
// within gecko. See comments below | |
// | |
addEventListener('fetch', function(event) { | |
event.respondWith( | |
event.default().then(function(response) { | |
caches.get('content').then(function(cache) { | |
var cacheResponse = response.clone(); | |
// Transfers data from network->parent process->disk | |
cache.put(request, cacheResponse).then(function(putResponse) { | |
// Transfers data from disk->parent process->child process | |
putResponse.body.asArrayBuffer(); | |
}); | |
// Transfers data from network->parent process->child process | |
var localResponse = response.clone(); | |
localResponse.body.asArrayBuffer(); | |
// Transfers data from network->parent process->child process | |
return response; | |
}) | |
}) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment