workbox-broadcast-update

    Summary

    Types

    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.

    Properties

    • constructor

      function

      Construct a BroadcastCacheUpdate instance with a specific channelName to broadcast messages on

      The constructor function looks like: (options?: BroadcastCacheUpdateOptions) => {...}

    • notifyIfUpdated

      function

      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/'
        }
      }
      

      The notifyIfUpdated function looks like: (options: CacheDidUpdateCallbackParam) => {...}

      • returns

        Promise<void>

        Resolves once the update is sent.

    BroadcastCacheUpdateOptions

    Properties

    BroadcastUpdatePlugin

    This plugin will automatically broadcast a message whenever a cached response is updated.

    Properties

    Methods

    responsesAreSame

    workbox-broadcast-update.responsesAreSame(
      firstResponse: Response,
      secondResponse: Response,
      headersToCheck: string[],
    )

    Given two Response's, compares several header values to see if they are the same or not.

    Parameters

    • firstResponse

      Response

    • secondResponse

      Response

    • headersToCheck

      string[]

    Returns

    • boolean

    We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.