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

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
updateViaCache
68
18
57
No
Yes
11.1
68
68
57
Yes
Yes
10.0

See also

© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration/updateViaCache