Skip to content

Commit

Permalink
Make caching optional
Browse files Browse the repository at this point in the history
  • Loading branch information
ljans committed Oct 12, 2019
1 parent 3620f3d commit c9339a7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions service.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* service.js for ServiceWorkers v1.2
* service.js for ServiceWorkers v1.4
* Licensed under the MIT license
* Copyright (c) 2019 Lukas Jans
* https://github.com/luniverse/service
Expand All @@ -22,9 +22,11 @@ Service = class {
// When ready, immediately replace the current service (if existing) by skipping its waiting-phase
self.skipWaiting();

// Cache resources
const cache = await caches.open(this.config.version);
cache.addAll(this.config.cache);
// Cache resources (an exception causes the promise to reject)
if(this.config.cache) {
const cache = await caches.open(this.config.version);
cache.addAll(this.config.cache);
}
}

// Activate the service (it now is the only one responsible for this scope)
Expand Down
4 changes: 2 additions & 2 deletions service.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c9339a7

Please sign in to comment.