1

I have a webpage that I initially started as a Blazor WASM project with PWA checked, because of the initial load time I decided to change it to a Blazor server project. Everything is working fine now except for desktops that had opened the page while it was a WASM project. They completely ignore the server and just run the original web page, if I do a shift-control-r the new web page with show up but anytime I go back it shows the original WASM page.

Does anyone know of a way to get the original wasm to update to the new version client side. I even shut the web server off and the webpage still works locally it is like it never even checks back with the server.

Thanks, Tim

2 Answers2

1

I finally found an answer for this that helped me. If you do not need PWA, you can remove it and Chrome (and probably other browsers) should stop clinging on to an old client even after deleting cache and fully reloading. Because after having done this my Chrome still reloaded it. For my app I do not need to use this caching feature or to be able to install it as an app.

I found the answer here: Blazor Chrome caching issues

How to remove PWA:

  1. Delete the following files from wwwroot:
/wwwroot/manifest.json
/wwwroot/service-worker.js
/wwwroot/service-worker.published.js
  1. Delete this line from /wwwroot/index.html
<script>navigator.serviceWorker.register('service-worker.js');</script>
  1. Delete those lines from your csproj file
<ServiceWorkerAssetsManifest>service-worker-assets.js</ServiceWorkerAssetsManifest>
<ServiceWorker Include="wwwroot\service-worker.js" PublishedContent="wwwroot\service-worker.published.js" />

Also... to actually get rid of the app in Chrome, because I had already loaded it this way, I installed it as an app and then uninstalled the app and removed it from Chrome. That finally got me out of this whole loop with Chrome keeping the app.

Kasper Olesen
  • 126
  • 1
  • 11
0

You can try using server pre-rendering for the PWA, that might help with the original speed issue, while letting the users who already have the PWA keep using it as one.

Updating the PWA version in the service worker and handling a few events can let you prompt your users to update. Frankly, if they have the old version - I am not sure there's much you can do in case they don't download the new service worker. I can suggest you take a peek at this sample app to see one way of doing such a custom prompt. I had a pal who had to drop an entire app and start using a different home page precisely because they couldn't get old service workers to drop the cache on client devices.

rdmptn
  • 5,413
  • 1
  • 16
  • 29
  • I liked the PWA idea and looked at the pre-rendering to help speed but without a good update mechanism that works independent of the user I decided to go back to server blazor. Hopefully there is another solution besides moving to another home page. – tjfdownsouth Jan 07 '21 at 21:38
  • Try updating the worker to include event handling for new versions, maybe those caching it will get the prompt and reload – rdmptn Jan 08 '21 at 00:42
  • 1
    Thanks for the suggestion, for now I just changed the domain and started with Blazor server and it seems to work as expected. I have tried everything I could find on the internet and WASM will not update unless the user does a hard refresh. It needs a better way to trigger an update from the host side. – tjfdownsouth Jan 10 '21 at 18:29