mirror of
https://github.com/Theodor-Springmann-Stiftung/hamann-ausgabe-core.git
synced 2025-10-29 09:15:33 +00:00
Set cache-control headers for static files to max one week
This commit is contained in:
@@ -68,6 +68,14 @@ if (!app.Environment.IsDevelopment()) {
|
||||
}
|
||||
|
||||
app.UseAuthorization();
|
||||
app.UseStaticFiles();
|
||||
|
||||
var cacheMaxAgeOneWeek = (60 * 60 * 24 * 7).ToString();
|
||||
app.UseStaticFiles(new StaticFileOptions {
|
||||
// Set ETag:
|
||||
OnPrepareResponse = ctx => {
|
||||
ctx.Context.Response.Headers.Add("Cache-Control", "public, max-age=" + cacheMaxAgeOneWeek);
|
||||
},
|
||||
ServeUnknownFileTypes = true,
|
||||
});
|
||||
app.MapControllers();
|
||||
app.Run();
|
||||
|
||||
Reference in New Issue
Block a user