From cf101e813e4e4afcbd1837134d4206484b5d1091 Mon Sep 17 00:00:00 2001 From: pooya parsa Date: Thu, 1 Oct 2020 14:45:09 +0200 Subject: [PATCH] docs: update usage for `strategyPlugins` --- docs/content/en/workbox.md | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/docs/content/en/workbox.md b/docs/content/en/workbox.md index fb91c278..73808f9a 100644 --- a/docs/content/en/workbox.md +++ b/docs/content/en/workbox.md @@ -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: