Skip to content
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

[Blazor WebAssembly standalone] Don't cache index.html during development #59340

Merged
merged 1 commit into from
Dec 5, 2024

Conversation

MackinnonBuck
Copy link
Member

[Blazor WebAssembly standalone] Don't cache index.html during development

Fixes an issue where the WebAssembly dev server (used during Blazor WebAssembly standalone development) returned index.html with incorrect caching headers, resulting in hot reload script injection sometimes being bypassed.

Description

The fix is to add the Cache-Control: no-store header to the response for index.html when running the app via the WebAssembly dev server. This prevents the browser from using a cached response, which bypasses the script injection middleware.

Fixes #59276

@MackinnonBuck MackinnonBuck added area-blazor Includes: Blazor, Razor Components feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly feature-hot-reload This issue is related to the Hot Reload feaature labels Dec 5, 2024
@MackinnonBuck MackinnonBuck requested a review from a team as a code owner December 5, 2024 18:26
@@ -40,7 +40,10 @@
<_FrameworkStaticWebAssetCandidate Remove="@(_MissingFrameworkStaticWebAssetCandidate)" />
</ItemGroup>

<Message Importance="High" Text="Framework asset '%(_MissingFrameworkStaticWebAssetCandidate.Identity)' could not be found and won't be included in the project." />
<Message
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unrelated to the main fix - it was logging a message even when _MissingFrameworkStaticWebAssetCandidate was empty.

@MackinnonBuck MackinnonBuck merged commit 7a5e55e into main Dec 5, 2024
27 checks passed
@MackinnonBuck MackinnonBuck deleted the mbuck/hot-reload-fix branch December 5, 2024 21:11
@dotnet-policy-service dotnet-policy-service bot added this to the 10.0-preview1 milestone Dec 5, 2024
@MackinnonBuck
Copy link
Member Author

/backport to release/9.0

Copy link
Contributor

github-actions bot commented Dec 5, 2024

Started backporting to release/9.0: https://github.com/dotnet/aspnetcore/actions/runs/12188138898

Copy link
Contributor

github-actions bot commented Dec 5, 2024

@MackinnonBuck backporting to release/9.0 failed, the patch most likely resulted in conflicts:

$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch

Applying: Don't cache index.html when running via Dev Sever
Using index info to reconstruct a base tree...
A	src/Assets/build/Microsoft.AspNetCore.App.Internal.Assets.targets
M	src/Components/WebAssembly/DevServer/src/Server/Startup.cs
M	src/Components/WebView/WebView/src/build/Microsoft.AspNetCore.Components.WebView.props
Falling back to patching base and 3-way merge...
Auto-merging src/Components/WebView/WebView/src/build/Microsoft.AspNetCore.Components.WebView.props
CONFLICT (content): Merge conflict in src/Components/WebView/WebView/src/build/Microsoft.AspNetCore.Components.WebView.props
Auto-merging src/Components/WebAssembly/DevServer/src/Server/Startup.cs
CONFLICT (modify/delete): src/Assets/build/Microsoft.AspNetCore.App.Internal.Assets.targets deleted in HEAD and modified in Don't cache index.html when running via Dev Sever. Version Don't cache index.html when running via Dev Sever of src/Assets/build/Microsoft.AspNetCore.App.Internal.Assets.targets left in tree.
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config advice.mergeConflict false"
Patch failed at 0001 Don't cache index.html when running via Dev Sever
Error: The process '/usr/bin/git' failed with exit code 128

Please backport manually!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-blazor Includes: Blazor, Razor Components feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly feature-hot-reload This issue is related to the Hot Reload feaature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Blazor WebAssembly] dotnet watch may not inject aspnetcore-browser-refresh.js after dotnet run
2 participants