Skip to content

ServiceWorkerAPI

Types

cache

Provides a storage mechanism for Request / Response object pairs that are cached, for example as part of the ServiceWorker life cycle. Note that the Cache interface is exposed to windowed scopes as well as workers. You don't have to use it in conjunction with service workers, even though it is defined in the service worker spec. See Cache on MDN

type cache = {}

Module

There are methods and helpers defined in Cache .

cacheQueryOptions

type cacheQueryOptions = {
mutable ignoreSearch?: bool,
mutable ignoreMethod?: bool,
mutable ignoreVary?: bool,
}

Record fields

ignoreSearch
option< bool >
ignoreMethod
option< bool >
ignoreVary
option< bool >

cacheStorage

The storage for Cache objects. See CacheStorage on MDN

type cacheStorage = {}

Module

There are methods and helpers defined in CacheStorage .

multiCacheQueryOptions

type multiCacheQueryOptions = {
mutable ignoreSearch?: bool,
mutable ignoreMethod?: bool,
mutable ignoreVary?: bool,
mutable cacheName?: string,
}

Record fields

ignoreSearch
option< bool >
ignoreMethod
option< bool >
ignoreVary
option< bool >
cacheName
option< string >
type navigationPreloadManager = {}

Module

There are methods and helpers defined in NavigationPreloadManager .

type navigationPreloadState = {
mutable enabled?: bool,
mutable headerValue?: string,
}

Record fields

option< bool >
option< string >

registrationOptions

type registrationOptions = {
mutable scope?: string,
mutable type_?: workerType,
mutable updateViaCache?: serviceWorkerUpdateViaCache,
}

Record fields

scope
option< string >
type_
option< workerType >
updateViaCache

requestInfo

type requestInfo = WebAPI.Prelude.any

serviceWorker

This ServiceWorker API interface provides a reference to a service worker. Multiple browsing contexts (e.g. pages, workers, etc.) can be associated with the same service worker, each through a unique ServiceWorker object. See ServiceWorker on MDN

type serviceWorker = {
scriptURL: string,
state: serviceWorkerState,
}

Record fields

scriptURL
string

Module

There are methods and helpers defined in ServiceWorker .

serviceWorkerContainer

The ServiceWorkerContainer interface of the ServiceWorker API provides an object representing the service worker as an overall unit in the network ecosystem, including facilities to register, unregister and update service workers, and access the state of service workers and their registrations. See ServiceWorkerContainer on MDN

type serviceWorkerContainer = {
controller: Null.t<serviceWorker>,
ready: Promise.t<serviceWorkerRegistration>,
}

Record fields

controller
Null.t< serviceWorker >

Module

There are methods and helpers defined in ServiceWorkerContainer .

serviceWorkerRegistration

This ServiceWorker API interface represents the service worker registration. You register a service worker to control one or more pages that share the same origin. See ServiceWorkerRegistration on MDN

type serviceWorkerRegistration = {
installing: Null.t<serviceWorker>,
waiting: Null.t<serviceWorker>,
active: Null.t<serviceWorker>,
navigationPreload: navigationPreloadManager,
scope: string,
updateViaCache: serviceWorkerUpdateViaCache,
pushManager: WebAPI.PushManagerAPI.pushManager,
}

Record fields

installing
Null.t< serviceWorker >
waiting
Null.t< serviceWorker >
active
Null.t< serviceWorker >
scope
string

Module

There are methods and helpers defined in ServiceWorkerRegistration .

serviceWorkerState

type serviceWorkerState =
| @as("activated") Activated
| @as("activating") Activating
| @as("installed") Installed
| @as("installing") Installing
| @as("parsed") Parsed
| @as("redundant") Redundant

serviceWorkerUpdateViaCache

type serviceWorkerUpdateViaCache =
| @as("all") All
| @as("imports") Imports
| @as("none") None

workerType

type workerType =
| @as("classic") Classic
| @as("module") Module