Need to clear application cache and then refresh to see the new changes on PWA enabled Blazor WebAssembly apps
See original GitHub issueFrom: @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:
- Deploy a blazor wasm app with pwa enabled.
- Now make some changes in
Index.razor
screen. - Now publish and deploy again and navigate to
index
url of the app. - 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:
- I have an intial version deployed.
- I made code change in
Index.razor
by adding<h1 style="background-color:yellow">Hello, Cache Problem</h1>
. - Published and deployed the app.
- Navigated to
index
url of the app. - Refreshed and expecting to see new changes but nothing happens.
- Cleared cache and refreshed. Now I can see new code changes.
Issue Analytics
- State:
- Created a year ago
- Comments:14 (8 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@fingers10
Yes. I’ll provide the ability on the NuGet package library I’m going to publish to customize UI fully.
@fingers10 [FYI] The “Blazor PWA Updater” NuGet package has been rolled out!
https://twitter.com/jsakamoto/status/1558456715237986309