ServiceWorkerRegistration.updateViaCache

The updateViaCache() method of the ServiceWorkerRegistration interface updates the cache using the mode specified in the call to ServiceWorkerContainer.register. Requests for `importScripts` still go via the HTTP cache. `updateViaCache` offers control over this behavior.

Syntax

serviceWorkerRegistration.updateViaCache;

Parameters

None.

Return value

Example

The following example shows the use of updateViaCache().

if ('serviceWorker' in navigator) {
  navigator.serviceWorker.register('/service-worker.js', {
    updateViaCache: 'none'
  });
  // When set to 'none', the HTTP cache will not be
  // consulted when making requests for either the top-level
  // /service-worker.js or for any imported scripted, such as
  // the hypothetical path/to/import.js.
}

Specifications

Specification
Service Workers 1
# service-worker-registration-updateviacache

Browser compatibility

BCD tables only load in the browser

See also