Skip to content

Commit

Permalink
return cache.put promise in chain
Browse files Browse the repository at this point in the history
after opening the cache, a put is executed and a log line is supposed to be written after the put is complete. `cache.put` returns a promise and returning it will wait the promise chain until that operation is complete and thus log the "response stored" message *after* the put is completed.
  • Loading branch information
jbielick committed May 30, 2017
1 parent 0673022 commit d57815f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion js/service-worker.js
Expand Up @@ -115,7 +115,7 @@ self.addEventListener("fetch", function(event) {
available to caches.match(event.request) calls, when looking
for cached responses.
*/
cache.put(event.request, cacheCopy);
return cache.put(event.request, cacheCopy);
})
.then(function() {
console.log('WORKER: fetch response stored in cache.', event.request.url);
Expand Down

0 comments on commit d57815f

Please sign in to comment.