Skip to content

Commit

Permalink
feat: cleanupOutdatedCaches
Browse files Browse the repository at this point in the history
  • Loading branch information
pooya parsa committed Feb 8, 2019
1 parent 16c4d84 commit 9167013
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/modules/workbox.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ Workbox takes a lot of the heavy lifting out of precaching by simplifying the AP

(String) Loads and inserts the contents of the specified file path into the service worker script, below autogenerated calls to `workbox.precaching.*`. You may add as many extra calls as you want to this file.

### `cleanupOutdatedCaches`

(Boolean) Find and remove any of the older precaches that might have been used by previous versions of Workbox.

<!-- Offline -->

### `offline`
Expand Down
1 change: 1 addition & 0 deletions packages/workbox/lib/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ module.exports = {
revision: undefined
},
cachingExtensions: [],
cleanupOutdatedCaches: true,

// Offline
offline: true,
Expand Down
4 changes: 4 additions & 0 deletions packages/workbox/templates/sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ workbox.core.clientsClaim()
workbox.core.skipWaiting()
<% } %>

<% if (options.cleanupOutdatedCaches) { %>
workbox.precaching.cleanupOutdatedCaches()
<% } %>

<% if (options.offlineAnalytics) { %>
// Enable offline Google Analytics tracking
workbox.googleAnalytics.initialize()
Expand Down
2 changes: 2 additions & 0 deletions test/__snapshots__/pwa.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ workbox.core.clientsClaim()
// Skip over the SW waiting lifecycle stage
workbox.core.skipWaiting()
workbox.precaching.cleanupOutdatedCaches()
// Enable offline Google Analytics tracking
workbox.googleAnalytics.initialize()
Expand Down

0 comments on commit 9167013

Please sign in to comment.