Blazor Wasm PWA not updating

Faheem Husain Rizvi 6 Reputation points
2023-01-23T17:19:09.8266667+00:00

After publishing blazor wasm app it will not updating it shows old version every time we performed hard reload and clearing cache and cookies then it will update. Please provide me solution to fix this issue

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,134 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,375 questions
0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. Tasadduq Burney 8,361 Reputation points MVP
    2023-01-23T17:37:09.8033333+00:00

    This issue is likely caused by the browser caching the old version of your Blazor WASM app. To fix this issue, you can try the following solutions:

    1. Add a cache busting mechanism to your app: This involves appending a unique query string parameter to the URLs of your app's assets (e.g. JavaScript and CSS files) every time you update and deploy your app. This will force the browser to download the new version of the assets.
    2. Set the appropriate cache control headers on your app's assets: By setting the "Cache-Control" header to "no-cache" or "no-store", you can ensure that the browser will always check for a new version of the assets before loading them.
    3. Use a service worker to handle caching: A service worker is a script that runs in the background of the browser and can control how assets are cached. By using a service worker, you can ensure that the browser always loads the latest version of your app.
    0 comments No comments

  2. Bruce (SqlWork.com) 54,866 Reputation points
    2023-01-23T18:20:13.3833333+00:00

    most browsers you can configure to not cache when the dev tools are open.

    0 comments No comments

  3. Marek Ištvánek 0 Reputation points
    2023-05-09T13:31:12.87+00:00

    I have the same problem.
    My Blazor Wasm PWA application for .NET 7 created in VS 2022 17.5 is not updated in a browser after it is uploaded to hosting.
    So basically the update process described at
    https://learn.microsoft.com/en-us/aspnet/core/blazor/progressive-web-app?view=aspnetcore-7.0&tabs=visual-studio#background-updates
    does not happen.
    I use Edge 113.0.1774.35 and close all browser tabs with my application.

    When I start the application again, it is never updated.

    When I open developer tools and click Update in Application part, the application is updated.

    0 comments No comments

  4. Bruce (SqlWork.com) 54,866 Reputation points
    2023-05-09T16:11:34.82+00:00

    the browsers trigger to update a PWA is a change to the manifest, or the service worker js file.

    the safest way to for users to get updates, is to change the urls in the service worker manifest file, by adding a version. you probably just need to make the WASM have a unique url.

    note: for development, just keep the dev tools open.

    0 comments No comments