mirror of
https://github.com/LD-Reborn/Berufsschule_HAM.git
synced 2025-12-20 06:51:55 +00:00
Improved loading times, improved SEO for lighthouse
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user