workbox-broadcast-update. BroadcastCacheUpdate
Uses 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
BroadcastCacheUpdate
new BroadcastCacheUpdate(options)
Construct a BroadcastCacheUpdate instance with a specific channelName
to
broadcast messages on
Parameter |
|||||||
---|---|---|---|---|---|---|---|
options |
Optional Object Values in
|
Method
notifyIfUpdated
notifyIfUpdated(options) returns Promise
Compares two Responses
and sends a message (via postMessage()
) to all window clients if the
responses differ (note: 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/'
}
}
Parameter |
|||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object Values in
|
- Returns
-
Promise
Resolves once the update is sent.