Incorrect "All files already uploaded" (with service worker)


I’m testing with having a service worker on my site and I run into issues surrounding updates to my site/worker. It might be a combination of issues, I’m still new to service worker struggles.

Some pains:

  • Sometimes I get index.html served at the sw.js (service worker) path
  • Often it seems like the browser doesn’t even check for new version of sw.js (in network tab). E.g. after closing/opening or clicking the devtool service worker update button.
  • Sometimes (when getting js) sw.js doesn’t have the latest contents.

While debugging not having the latest contents, I downloaded the deploy and confirmed changes missing in sw.js. I also confirmed the commit has the changes by clicking it and logging into gitlab (private).
The deploy page: Netlify App says it has All files already uploaded. I can probably find a way to get the changes, perhaps with clear cache and retry. But i’d like to understand when and why it doesn’t update. Some thoughts about why I had myself:

  • Maybe having the same commit message was at fault (different SHA and contents though).
  • Perhaps my combination of Angular build + workbox build has Netlify checking only Angular part.
  • Perhaps changes are too minor. However, this commit has a clear enough change: it should add const newValueForForcedHashing = '1718888265'; to the end of sw.js.

Also if I could get help on the other pain points (index.html served at sw.js, or not discovering a changed sw.js) that would be great! One thing I have doubts about, is caching caused by headers. These are some of the response headers when I request sw.js in a fresh chrome incognito window.

Request URL:
Cache-Status:“Netlify Edge”; fwd=stale
Strict-Transport-Security:max-age=31536000; includeSubDomains; preload

Thanks in advance for any help!

I might have jumped to conclusions with “All files already uploaded” being incorrect.

My changes are in the file swtemplate.ts (not in dist) and should be reflected in sw.js (in dist), but aren’t. I only noticed after my post that the same happens in my local build. Both logs suggest the service worker file was written successfully.

I’ll keep trying to understand the issue(s).

Edit 1: my swtemplate.ts changes were also already lost after transpiling to swtemplate.js, probably because the new variable was unused. It did transpile with the change when setting mode: 'development', (unminified) in webpack.config.ts.

Getting index.html served at the sw.js (service worker) path, and not seeing any network activity when I click update in the service worker tab, might both be due to the browser getting these service worker updates quite differently from other types of requests/navigation.

Getting the html happened consistently with these steps:
cognito tab1 address: url/sw.js (script contents)
cognito tab2 address: url (app loads, installs sw)
cognito tab3 address: url/sw.js (index.html contents)
but using the address bar seems not the same as the requests the browser makes for getting service worker updates. When the browser checks, I think it will only show a record in the network tab if it recognizes that the update should be downloaded.

I think I understand now and there might not be any issues.