ServiceWorkerGlobalScope: activate event

The activate event of the ServiceWorkerGlobalScope interface is fired when a ServiceWorkerRegistration acquires a new worker.

Bubbles No
Cancelable No
Interface ExtendableEvent
Event handler property ServiceWorkerGlobalScope.onactivate


The following snippet shows how you could use an activate event handler to upgrade a cache.

globalScope.addEventListener('activate', function(event) {
  var cacheAllowlist = ['v2'];

    caches.forEach(function(cache, cacheName) {
      if (cacheAllowlist.indexOf(cacheName) == -1) {
        return caches.delete(cacheName);

You can also set up the event handler using the ServiceWorkerGlobalScope.onactivate property:

globalScope.onactivate = function(event) {


Service Workers 1
# service-worker-global-scope-activate-event

Browser compatibility

BCD tables only load in the browser

See also