[Blazor] Update service-worker registration to prevent caching issues#62382
Merged
[Blazor] Update service-worker registration to prevent caching issues#62382
Conversation
Copilot
AI
changed the title
[WIP] [Blazor] Update service-worker registration to prevent caching issues
[Blazor] Update service-worker registration to prevent caching issues
Jun 17, 2025
This was referenced Jun 18, 2025
ilonatommy
approved these changes
Jun 18, 2025
Member
ilonatommy
left a comment
There was a problem hiding this comment.
I don't see a problem with disabling cache but I would wait for @maraf to share his opinion.
Member
For context, browsers don't ever cache the service-worker file, but will cache scripts that are loaded by it, which is what caused problems in the past for our service worker (since we generate an assets.js file). |
maraf
approved these changes
Jun 18, 2025
Member
|
@copilot rebase the PR |
Contributor
Author
Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
5d7c8bb to
4c6fecf
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR updates the service worker registration in the Blazor WebAssembly PWA template to include the
updateViaCache: 'none'option, which prevents caching issues during service worker updates.Changes Made
Updated the service worker registration in
src/ProjectTemplates/Web.ProjectTemplates/content/ComponentsWebAssembly-CSharp/wwwroot/index.html:Before:
After:
Why This Change is Needed
The
updateViaCache: 'none'option ensures that:This addresses caching issues that can prevent service worker updates from being applied correctly, which is particularly important for PWAs that rely on service workers for offline functionality.
Verification
dotnet new blazorwasm --pwa) now include the updated registrationFixes #44635.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.