I am experiencing the same, or a very similar, problem as was reported here by Linwe: Angular : service worker configuration (no answer at the time of this question).
I created a new project using the Angular CLI, and then added support for service workers, following the steps set out here: https://angular.io/guide/service-worker-getting-started. I changed the content of the site to say nothing more than “This is the App Component,” so it is extremely simple, with no functionality. I'm just trying to test service workers alone.
The service worker technology uses a file called “manifest.webmanifest”, which had no MIME type defined in my local IIS, so I added it (application/manifest+json). But even then my web browser (Chrome) could not always find the file (and was getting the index.html page instead on the fetch request). But, according to manifest.json vs manifest.webmanifest, there is nothing magical in the name, so I added ".json" to the end of the file, and modified references to work with that name instead. That seems to be working fine.
Running in Visual Studio 2019 (using IIS Express, and handling requests on https://localhost:44303/), the service worker was never created at all. When I went to the Application tab of Chrome's DevTools, and looked for service workers, I saw nothing.
But when I deployed the site to my local IIS, I could see (either under http or under https) that the service worker was created and running:
And when, running online, I could see that content was being served from the service worker (like Linwe). But when I went to the Network tab and put the browser offline, I got the same error as if I were not using service workers at all:
In the network tab, I see a failed fetch command (expected??), but I'm not seeing any other errors:
I am only moving to service workers for this (fairly simple) application because Chrome is discontinuing support for AppCache in April. I don't know what alternative there is if the service workers won't work in Chrome...
Any help would be most greatly appreciated.
(I note that Linwe indicated his issue was only on browsers running on Windows - he said that browsers running on a MAC were OK. I don't have a MAC to verify it, but that comment suggests something specific to Windows.)
UPDATE: I started over, following exactly the steps set out here: https://angular.io/guide/service-worker-getting-started. Then I ran it using http-server, and everything worked perfectly. I took it offline, and refreshed the page, and saw the cached content.
Then I took that complete project and copied all of the files into the ClientApp folder of a Visual Studio 2019 Angular project (after first deleting all files from that folder). Then I published it to my local IIS, and got the same problem as reported previously. The service worker is created and I can see it, but when going offline I don't get any cached content. The only change I made was to the outputPath in my angular.json file, because I wanted it deployed to the root of the dist directory, not to a subfolder beneath the dist directory (where IIS could not find it).
Then, to further experiment, I copied all the files from the dist/[project name] folder in the original application created via the CLI and placed them at the root of the application folder in IIS (after first deleting all other files). I changed the base href of the index.html file to match the application name, but made no other changes. And, again, I see the same problem as originally reported - I see the service worker, but cached content is not served when offline. (This happens whether I hit the IIS site via http or https - makes no difference.)
So, it seems to me that the exact same files which run and function correctly when I am serving them with http-server do not work correctly when my server is IIS (this is on a Windows 10 professional PC).
Where do I go from here???