Skip to content

Commit 4b277b8

Browse files
authored
Incorporate changes from dotnet/aspnetcore#59340
1 parent 3bbd403 commit 4b277b8

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/mono/wasm/host/DevServer/DevServerStartup.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ public static void Configure(IApplicationBuilder app, IOptions<DevServerOptions>
6767
ServeUnknownFileTypes = true,
6868
});
6969

70-
app.UseRouting();
7170
app.UseWebSockets();
7271

7372
if (options.OnConsoleConnected is not null)
@@ -100,6 +99,14 @@ public static void Configure(IApplicationBuilder app, IOptions<DevServerOptions>
10099
{
101100
OnPrepareResponse = fileContext =>
102101
{
102+
// Avoid caching index.html during development.
103+
// When hot reload is enabled, a middleware injects a hot reload script into the response HTML.
104+
// We don't want the browser to bypass this injection by using a cached response that doesn't
105+
// contain the injected script. In the future, if script injection is removed in favor of a
106+
// different mechanism, we can delete this comment and the line below it.
107+
// See also: https://github.com/dotnet/aspnetcore/issues/45213
108+
fileContext.Context.Response.Headers[HeaderNames.CacheControl] = "no-store";
109+
103110
if (options.WebServerUseCrossOriginPolicy)
104111
{
105112
// Browser multi-threaded runtime requires cross-origin policy headers to enable SharedArrayBuffer.

0 commit comments

Comments
 (0)