Offline issue with Blazor WebAssembly

Pedro Batista 0 Reputation points
2023-11-06T18:41:45.5633333+00:00

I have a blazor webassembly app that communicates with an API to read/write a lot of data, and when the app is offline it consumes data from IndexedDB. I've spent a couple of months on this project and it's working great, even offline (kinda). I downloaded it on my phone and tested all scenarios online and offline.

The problem is if I'm offline and I haven't used the app for more than a day, next time I open it it doesn't load anything, a message is prompted to me saying "You're offline". To fix this I have to turn on my data, get the app running, then turn the data off again and then I'll be able to use it in offline mode.

Has anyone ever seen this behaviour before? It's crucial that the app works offline regardless of the amount of days the user hasn't used it.

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
3,773 questions
Blazor
Blazor
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,208 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 48,711 Reputation points
    2023-11-07T17:47:51.11+00:00

    did you use the PWA template?

    offline loading of the app is support by the service-worker.js file in wwwroot folder. the service worker should cache all the files required load the app.

    I would have thought that the server worker managed the indexDB file.

    learn about PWA and service worker:

    https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps

    0 comments No comments