Skip to main content

BroadcastUpdatePlugin

First added

Workbox

About

A class implementing the cacheDidUpdate lifecycle callback. It will automatically broadcast a message whenever a cached response is updated.

Options

See BroadcastCacheUpdate’s options.

Usage

import { BroadcastUpdatePlugin, StaleWhileRevalidate } from "serwist";

serwist.registerCapture(
  ({ url }) => url.pathname.startsWith("/api/"),
  new StaleWhileRevalidate({
    plugins: [new BroadcastUpdatePlugin()],
  }),
);