[Blazor WebAssembly standalone] Don't cache index.html during development by MackinnonBuck · Pull Request #59340 · dotnet/aspnetcore (original) (raw)

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 andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation4 Commits1 Checks27 Files changed

Conversation

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

[ Show hidden characters]({{ revealButtonHref }})

MackinnonBuck

[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

@@ -40,7 +40,10 @@
<_FrameworkStaticWebAssetCandidate Remove="@(_MissingFrameworkStaticWebAssetCandidate)" />
<Message

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.

javiercn

@MackinnonBuck

@github-actions GitHub Actions

@github-actions GitHub Actions

@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!

wtgodbe pushed a commit that referenced this pull request

Jan 9, 2025

@MackinnonBuck

wtgodbe pushed a commit that referenced this pull request

Jan 9, 2025

@github-actions @MackinnonBuck

Co-authored-by: Mackinnon Buck mackinnon.buck@gmail.com

maraf added a commit to maraf/runtime that referenced this pull request

Jan 10, 2025

@maraf

@maraf maraf mentioned this pull request

Jan 10, 2025

2 participants

@MackinnonBuck @javiercn