title: Strange Angular PWA Service worker behaviour when deployed
body: <p>This issue has taken up all my day, and I can't figure out whats going on</p>
  
  <p>I can see that my service worker is registered , however "sometimes" when I click offline in developer tools the ServiceWorker for my domain just disappears!!</p>
  
  <p>But this is the main problem when I reload the app I see the following behaviour.</p>
  
  <p>You can see the ngsw.json is loaded twice and the main.js is loaded 3 times! main.d3ae2084xxxx &amp;&amp; main.bbe5073dxxxx &amp;&amp; then main.d3ae2084xxxx again!</p>
  
  <p><a href="https://i.stack.imgur.com/SfxlW.png" rel="noreferrer"><img src="https://i.stack.imgur.com/SfxlW.png" alt="enter image description here"></a></p>
  
  <p>If I inspect the response of both ngsw.json requests you can see that both show main.d3ae2084xxxx as the correct version of main.js but it still loads main.bbe5073dxxxx... </p>
  
  <p>First ngsw.json request</p>
  
  <p><a href="https://i.stack.imgur.com/GQcTB.png" rel="noreferrer"><img src="https://i.stack.imgur.com/GQcTB.png" alt="enter image description here"></a></p>
  
  <p>Second ngsw.json request</p>
  
  <p><a href="https://i.stack.imgur.com/Aq39Z.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Aq39Z.png" alt="enter image description here"></a></p>
  
  <p>Whats even more frustrating is the actual loaded version is the previous main.bbe5073dxxxx...!!!!</p>
  
  <p>If anyone has any ideas how this can be happening please let me know.</p>
  
  <p><strong>Update...</strong> So found out about this excellent little endpoint </p>
  
  <pre><code>https://you-app-url/ngsw/state 
  </code></pre>
  
  <p>This will give you lots of debug information about your service worker.</p>
  
  <p>In my case this </p>
  
  <blockquote>
    <p>Driver state: EXISTING_CLIENTS_ONLY (Degraded due to failed
    initialization: Hash mismatch (cacheBustedFetchFromNetwork):
    <a href="https://dev-xxxx.net/main.eb8468bb3ed28f02d7c2.js" rel="noreferrer">https://dev-xxxx.net/main.eb8468bb3ed28f02d7c2.js</a>: expected
    b5601102b721e0cf777691d327dc965d40d1c96e, got
    83c18fdb4a5942c964a31c119a57e0b8e16fe46e (after cache busting)</p>
  </blockquote>
  
  <p>So looks like this is going to be a CDN issue of some sort in my case, will update with an answer when I know for sure.</p>