25

In case of our development, we serve files from https://localhost as the app is hosted in salesforce.com. In chrome service worker on chrome blocks anything coming from self-signed server i.e (https://localhost).

So is there a way to disable/unregister service workers when in development mode. Any pattern to follow for this.

Thanks

Kiba
  • 8,180
  • 6
  • 24
  • 30

2 Answers2

37

You can use the chrome devtools, and under Application>Service Workers path select the Update on refresh checkbox

enter image description here

You can also use the Bypass for network checkbox to avoid Service worker's register event form firing.

kano
  • 4,625
  • 2
  • 25
  • 38
Aditya Singh
  • 13,438
  • 12
  • 35
  • 62
4

Here is a brute-force approach:

const fn = () => {};

navigator.serviceWorker.register = () => new Promise(fn, fn);

(tested in Chrome Canary and Firefox Developer Edition)

cantera
  • 21,869
  • 22
  • 87
  • 128