angularservice-worker

Force Angular ServiceWorker to only proxy DataGroups / AssetGroups


By default the Angular ServiceWorker (ng add @angular/pwa) proxies all request but not only requests listed in it's configuration file (ngsw-config.json).

The problem is that some custom offline mechanisms rely on a native offline response (error code 0 instead of 504 [responded by ngsw]).

My questions are:

  1. Is it possible to only proxy mentioned requests from configuration file? I've used an interceptor for this (request = request.clone({ setHeaders: { 'ngsw-bypass': 'true' } });) but that e.g. broke mat-icon (relying on HttpClient) and only intercepts HttpClient. I just want my page to behave totally normal as long as no special endpoints are requested
  2. Just out of curiosity: why does it proxy requests at all? Does it save all content dependent on its cache header to not rely on default browser behavior? And if so, what are it's quotas? Have found nothing about it in the docs.

Solution

  • Technically not possible and (currently) not planned: https://github.com/angular/angular/issues/60950