简体   繁体   中英

Instantly update DOM when service worker detects a change

Is there any way to have service workers fetch the cached version, then attempt to do a.network fetch, and if it's different than the cached version, put that new thing in the cache and replace the old asset in the DOM with the new one instantly (without having to refresh the page)?

Hey yeah this is a very tricky situation but what I did was save a version number to my.env file on production release.

I then built this NPM package which will surface the Version number of the.env at build time. I could then use this number in my VueJS - PWA to check against the old currently cached version number, and then do a.network request if they dont match.

https://www.npmjs.com/package/vue-enverywhere

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM