Hey,
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:https://feature-test--compassionate-lamport-a24cee.netlify.app/sw.js
Cache-Control:public,max-age=0,must-revalidate
Cache-Status:“Netlify Edge”; fwd=stale
Etag:“b6b28df863c728f6129c8638e603b51f-ssl-df”
Strict-Transport-Security:max-age=31536000; includeSubDomains; preload
X-Nf-Request-Id:01J0WW2NW1JX1R6KCENXF7M9WN
Thanks in advance for any help!