PlatformPlatform
PlatformPlatform copied to clipboard
Add cache control for serving WebApp static files
One of the Lighthouse findings relates to static files not being aggressively cached in the WebApp Middleware pipeline.
Currently all JavaScript bundles are hashed using "real content hash" enabling invalidation, images stored in the public
folder will have to be "manually" invalidated e.g. by renaming (in future releases images will also be applied the real content hash)
Reference:
app.UseStaticFiles(new StaticFileOptions
{
OnPrepareResponse = ctx =>
{
ctx.Context.Response.Headers.Append(
"Cache-Control", $"public, max-age={TimeSpan.FromDays(365).Seconds}");
}
});