Great Article Thanks. But my opinion service-worker for this case is a better solution. You can easily detect if site new version available, and notify your users. And its also enables good content caching.
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.
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.
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?
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).
Great Article Thanks. But my opinion service-worker for this case is a better solution. You can easily detect if site new version available, and notify your users. And its also enables good content caching.
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.
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.
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?
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).
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 :(