question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Need to clear application cache and then refresh to see the new changes on PWA enabled Blazor WebAssembly apps

See original GitHub issue

From: @fingers10
(The original post is in the Issue #17)


@jsakamoto The fix provided in the service-worker.published.js,

Change the code inside the onFetch() function from const request = shouldServeIndexHtml ? 'index.html' : event.request; to const request = shouldServeIndexHtml ? (new URL(event.request.url)).pathname.replace(/\/$/, '') + '/index.html' : event.request;.

creates a cache issue.

Steps:

  1. Deploy a blazor wasm app with pwa enabled.
  2. Now make some changes in Index.razor screen.
  3. Now publish and deploy again and navigate to index url of the app.
  4. Note that new changes will not be reflected. You need to clear application cache and then refresh to see the new changes.

Video showing the problem:

  1. I have an intial version deployed.
  2. I made code change in Index.razor by adding <h1 style="background-color:yellow">Hello, Cache Problem</h1>.
  3. Published and deployed the app.
  4. Navigated to index url of the app.
  5. Refreshed and expecting to see new changes but nothing happens.
  6. Cleared cache and refreshed. Now I can see new code changes.

https://user-images.githubusercontent.com/43729469/181191463-58db8227-1366-43ec-ab0d-527e7ebd31f6.mp4

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:14 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
jsakamotocommented, Aug 11, 2022

@fingers10

Can we supply a custom UI to refresh and get new content instead of default one?

Yes. I’ll provide the ability on the NuGet package library I’m going to publish to customize UI fully.

1reaction
jsakamotocommented, Aug 13, 2022

@fingers10 [FYI] The “Blazor PWA Updater” NuGet package has been rolled out!

https://twitter.com/jsakamoto/status/1558456715237986309

Read more comments on GitHub >

github_iconTop Results From Across the Web

Blazor Wasm PWA not updating - Microsoft Q&A
After publishing blazor wasm app it will not updating it shows old version ... hard reload and clearing cache and cookies then it...
Read more >
Forcing reload of Blazor client after publishing changes
How can I force a reload of the client when I publish my changes? Do I have to tell the browser not to...
Read more >
Blazor WASM PWA — Adding a “New Update Available ...
In this article, I want to explain why and how we can add a “New Update Available” notification to a Blazor WebAssembly PWA...
Read more >
How to refresh cache in PWA app? : r/Blazor
My app does not update automatically on new versions (I use WASM). Since it's PWA the `no-cache` header does not do anything.
Read more >
Blazor WASM caching persists even with 'no-cache' header ...
I am unable to clear the cache automatically when I publish a new version in blazor, I have checked online and most solution...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found