Skip to content

Commit

Permalink
docs: update usage for strategyPlugins
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Oct 1, 2020
1 parent bed6af7 commit cf101e8
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions docs/content/en/workbox.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,21 +237,29 @@ workbox: {
urlPattern: 'https://my-cdn.com/posts/.*',
strategyOptions: {
cacheName: 'our-cache',
plugins: [{
// Use Workbox plugins, available options are 'BackgroundSync', 'BroadcastUpdate', 'CacheableResponse', 'Expiration' and 'RangeRequests'
use: 'Expiration',
// Pass parameter values of the plugin's constructor as an array. Function in parameter is not supported.
config: [{
maxEntries: 10,
maxAgeSeconds: 300
}]
}]
}
},
strategyPlugins: [{
use: 'Expiration',
config: {
maxEntries: 10,
maxAgeSeconds: 300
}
}]
}
]
}
```

This strategy plugins are supported (possible values for `strategyPlugins[].use`):

- BackgroundSync
- BroadcastUpdate
- CacheableResponse
- Expiration
- RangeRequests

You can pass an array for `strategyPlugins[].config` if it supports more than one argument. Only JSON serializable values are supported (for example you cannot pass an inline function as config)

### Adding custom service worker

Create `static/custom-sw.js` file:
Expand Down

0 comments on commit cf101e8

Please sign in to comment.