Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cache control for serving WebApp static files #363

Open
raix opened this issue Mar 4, 2024 · 0 comments
Open

Add cache control for serving WebApp static files #363

raix opened this issue Mar 4, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@raix
Copy link
Contributor

raix commented Mar 4, 2024

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)

Image

Reference:

app.UseStaticFiles(new StaticFileOptions
{
    OnPrepareResponse = ctx =>
    {
        ctx.Context.Response.Headers.Append(
             "Cache-Control", $"public, max-age={TimeSpan.FromDays(365).Seconds}");
    }
});
@tjementum tjementum added the enhancement New feature or request label Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: 🔖 Ready
Development

No branches or pull requests

2 participants