diff --git a/src/Program.cs b/src/Program.cs index 0dad9d7..9c35a95 100644 --- a/src/Program.cs +++ b/src/Program.cs @@ -48,8 +48,8 @@ builder.Services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationSc builder.Services.AddResponseCompression(options => { options.EnableForHttps = true; - options.MimeTypes = new[] - { + options.MimeTypes = + [ "text/plain", "text/css", "application/javascript", @@ -58,7 +58,7 @@ builder.Services.AddResponseCompression(options => "text/xml", "application/json", "image/svg+xml" - }; + ]; }); var app = builder.Build(); @@ -89,7 +89,22 @@ if (app.Environment.IsDevelopment()) app.UseSwaggerUI(); } -app.UseStaticFiles(); +app.UseStaticFiles(new StaticFileOptions +{ + OnPrepareResponse = ctx => + { + string requestPath = ctx.Context.Request.Path.ToString(); + if (requestPath.EndsWith(".css") || requestPath.EndsWith(".js")) + { + ctx.Context.Response.GetTypedHeaders().CacheControl = + new Microsoft.Net.Http.Headers.CacheControlHeaderValue() + { + Public = true, + MaxAge = TimeSpan.FromDays(365) + }; + } + } +}); app.UseRouting(); app.UseAuthorization(); app.UseResponseCompression(); diff --git a/src/Views/Shared/_Layout.cshtml b/src/Views/Shared/_Layout.cshtml index 857088e..6ca4965 100644 --- a/src/Views/Shared/_Layout.cshtml +++ b/src/Views/Shared/_Layout.cshtml @@ -4,15 +4,17 @@ + @ViewData["Title"] - Berufsschule_HAM - @* *@ + @* *@ - - + @* *@ + + @@ -71,10 +73,10 @@ © 2025 - Berufsschule_HAM - @* *@ + @* *@ - @* *@ + @* *@