English
BroadcastCacheUpdate
Class @vite-pwa/workbox-swkit/broadcast-updateUses the postMessage() API to inform any open windows/tabs when a cached response has been updated.
For efficiency's sake, the underlying response bodies are not compared; only specific response headers are checked.
Constructor
ts
new BroadcastCacheUpdate(options?: BroadcastCacheUpdateOptions)Construct a BroadcastCacheUpdate instance with a specific channelName to broadcast messages on
Methods
notifyIfUpdated()
ts
notifyIfUpdated(options: CacheDidUpdateCallbackParam): Promise<void>Compares two Responses and sends a message (via postMessage()) to all window clients if the responses differ. Neither of the Responses can be opaque.
The message that's posted has the following format (where payload can be customized via the generatePayload option the instance is created with):
{
type: 'CACHE_UPDATED',
meta: 'workbox-broadcast-update',
payload: {
cacheName: 'the-cache-name',
updatedURL: 'https://example.com/'
}
}Returns: Resolves once the update is sent.