-
Notifications
You must be signed in to change notification settings - Fork 10.4k
[Blazor] Update service-worker registration to prevent caching issues #62382
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see a problem with disabling cache but I would wait for @maraf to share his opinion.
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). |
@copilot rebase the PR |
Co-authored-by: javiercn <[email protected]>
5d7c8bb
to
4c6fecf
Compare
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.