DEV Community

Discussion on: Create react app version check

Collapse
 
jonocairns profile image
Jono Cairns

Yep - there definitely are more intricate solutions, the cost is more time to build. deanhume.com/displaying-a-new-vers... is a pretty good guide on how to use service workers for the same thing. My example is mainly for when you need something quick and simple without having to deal with the potential complexity that service workers can bring.

Collapse
 
khorengrig profile image
khorengrig

Agree with you. Service worker can bring complexity. But
Google Workbox makes it easier. A few months ago I had a problem with chunk errors. My users were getting this erros (during navigation, because the requested file had already been deleted from server) every time when I was deploying new a content in live. I tried multiple ways to solve this problem(including poling to server with timeout). And also had problem with content caching, and my solution was SW.

Thread Thread
 
jonocairns profile image
Jono Cairns • Edited

Nice - thanks for posting that :) Caching files with a SPA is always tough, there are so many layers things can go wrong and debugging is non-trivial. How did you end up informing the user that you essentially needed to block the UI and prompt a reload? Or did you just onError refresh the page so it'd grab the latest?

Thread Thread
 
khorengrig profile image
khorengrig

I am just roughly refreshing all opened tabs (if they are multiple) and they grab latest content, without any side action and SW automatically revalidates it's cache. But would be nice to inform user to do it yourself :D (with a custom prompt).

Thread Thread
 
jonocairns profile image
Jono Cairns

Ah I see. Our application has a voice/video call function so we're unable to refresh randomly, as someone could be in a call :(