school Are you a developer in an agency in the UK, Indonesia or India? Find out more about our free 2 day Progressive Web Apps training .

Examples

This page contains examples for some of the Workbox modules.

Workbox is a set of small modules that can be used on their own, but we've also combined the most common pieces into one module, workbox-sw. This module supports precaching, routing of fetch events, runtime caching and more.

workbox-sw

The workbox-sw example demonstrates a complete service worker implementation, demonstrating the common parts of the API. It's an in-depth exploration of everything you'd need to build a production-ready service worker.

View Example

Lower Level Modules

As an alternative to using the full workbox-sw library, you can use these smaller, standalone modules in your service worker.

workbox-broadcast-cache-update

Uses the Broadcast Channel API to let you know when two responses are different.

View Example

workbox-cache-expiration

Takes care of expiring cached entries based on the maximum number or age of entries.

View Example

workbox-routing

Makes it easy to handle network requests using the response strategy of your choice.

View Example

workbox-runtime-caching

Implements common cache strategies, and provides hooks to extend the default behaviors.

View Example