Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Manually Updating a Blazor WebAssembly App

We are on the verge of releasing our first Blazor WebAssembly stand alone (i.e. not hosted on .Net Core) app. I've come to love Blazor and look forward to producing some great apps with it! However pushing app updates has been a headache! There seems to be a persistent cache that is hard to update and it is super annoying! Likely it is my lack of understanding but it does not seem to work like everyone says it should.

I would like to build some kind of app versioning system and a way to notify users that an update is available. Most important of all I would like to give users the ability to manually perform an update... but searching for this topic has been difficult. I must not be using the right keywords as there seems to be no documentation on this for Blazor?

If I leave Blazor out of my search query it seems that other SPA applications do this via the Service Worker if I am understanding it correctly? However this is a whole other deep subject into itself and apparently something that I will have to learn if my understanding is correct?

Can anyone lead me in the right direction in how I can learn about creating such an update process?

like image 473
Anthony Griggs Avatar asked Sep 05 '25 01:09

Anthony Griggs


1 Answers

Ok... so my answer is a patch for now. It took a while to figure out because I had an idea of what was happening... in not being able to clear the cache like I wanted... I just didn't understand why. Lots of tutorials and training on Blazor but the service worker should be one of those that should be included for WebAssembly apps. Unfortunately at this time I couldn't find anything until I left Blazor out of my Google searches and just researched SPA caching issues in general.

Granted, the service worker itself is not Blazor specific technology... however if you are building SPA's it's something you should at the very least be aware of and learn how to use. However it's not a light subject so for now I simply commented out all of the code in service-worker.published.js and replaced it with the one liner service worker that is used for development i.e. the service-worker.js file: enter image description here

I know this isn't a final fix... eventually I will have to take pickup learning how to use the service worker to it's full extent. But for now it works as I want in that I want my development changes to be immediately available.

like image 103
Anthony Griggs Avatar answered Sep 07 '25 17:09

Anthony Griggs