Stay up to date on releases
Create your free account today to subscribe to this repository for notifications about new releases, and build software alongside 40 million developers on GitHub.
Sign up for free See pricing for teams and enterprises
jeffposnick
released this
π What's New?
More customization when generating a service worker
Developers who use Workbox to generate their service worker (using the CLI, Node interface, or webpack plugin) can now take advantage of some additional options:
-
Setting
offlineGoogleAnalytics: truewill automatically add code to initialize Workbox's offline Google Analytics support in the generated service worker. -
Both
fetchOptionsandmatchOptionscan now be used when configuring aruntimeCachingroute, and those values will be passed through when constructing the corresponding Workbox caching strategy. Many thanks to @peterjosling for contributing this in #1608. -
Using a custom plugin within a
runtimeCachingroute is now possible, thanks to enhancements made by @tsirlucas in #1598.
Here's a snippet of Workbox's build configuration, showing off all of the new features:
{
// ... other options ...
offlineGoogleAnalytics: true,
runtimeCaching: {[
urlPattern: /abc/,
handler: 'staleWhileRevalidate',
options: {
fetchOptions: {
mode: 'no-cors',
},
matchOptions: {
ignoreSearch: true,
},
plugins: [{
cacheDidUpdate: async ({cacheName, request, oldResponse, newResponse}) => {
// Do something in your custom plugin.
},
}],
},
]},
}Support for the PATCH method in Workbox's router
Developers who need to match HTTP PATCH requests using Workbox's router can now do so, thanks to @kevin-brotcke's change in #1618.
Note that non-GET requests can't be added to a cache, so this is most useful when used alongside a network-only strategy configured with the Workbox background sync plugin, in order to retry failed PATCH requests once the network becomes available.
workbox.core.registerQuotaErrorCallback is now publicly visible
Due to a scoping error, the workbox.core.registerQuotaErrorCallback() function was previously not exposed. This is now public, matching the documented interface. Thanks to @Tronil for pointing out this discrepancy in #1616.
π Learn More
Check out our docs @ developers.google.com/web/tools/workbox/