How’d they code the NNS front end to do this?

We do not register a custom service worker.

Long story short, at the moment if your application is served through the .ic0.app domain you cannot register a custom service worker without a workaround.

The reason behind is the fact that the IC answer to http queries with an html answer that automatically register a service worker which takes care of certifying all resources that will be downloaded by the browser for security reason. In other words: even if you don’t register a service worker there is actually already one that is registered for you.

As a workaround, you can register a custom worker from the raw domain. For example: /_/raw/service-worker.js. However if do so, you might not be able to use all features of a service worker anyway.

There is no such limitation if you serve your app directly through the .raw.ic0.app domain but it’s generally not the best practice as you loose the certification explained above.

Side note: as a web developer I dislike this limitation or issue (depends the point of view). It’s one of my top two features which I bring to the table on a weekly basis. Hopefully it will be solved in the future.

2 Likes