Skip to content

Commit

Permalink
Disable cache for index file
Browse files Browse the repository at this point in the history
  • Loading branch information
chrishamm committed Oct 20, 2023
1 parent b9d4fd3 commit 6dc855a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/DuetWebServer/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,16 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IService
{
OnPrepareResponse = ctx =>
{
ctx.Context.Response.Headers[HeaderNames.CacheControl] = $"public,max-age={_configuration.GetValue("MaxAge", 3600)},must-revalidate";
ctx.Context.Response.Headers[HeaderNames.Expires] = "0";
if (ctx.Context.Request.Path.Equals("/"))
{
ctx.Context.Response.Headers[HeaderNames.CacheControl] = "no-store,no-cache,must-revalidate";
ctx.Context.Response.Headers[HeaderNames.Pragma] = "no-cache";
}
else
{
ctx.Context.Response.Headers[HeaderNames.CacheControl] = $"public,max-age={_configuration.GetValue("MaxAge", 3600)},must-revalidate";
ctx.Context.Response.Headers[HeaderNames.Expires] = "0";
}
}
});
app.UseFileServer(new FileServerOptions
Expand Down

0 comments on commit 6dc855a

Please sign in to comment.