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

      void

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

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

    • notifyIfUpdated

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

      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

    This site uses cookies to deliver and enhance the quality of its services and to analyze traffic. If you agree, cookies are also used to serve advertising and to personalize the content and advertisements that you see. Learn more about our use of cookies.