Response caching: add StaticFileOptions to app.UseSpaStaticFiles() method #280

Closed
opened 2025-08-09 17:15:41 +00:00 by fergalmoran · 0 comments
Owner

Originally created by @ridicoulous on 12/8/2017

Hello. How about to add StaticFileOptions to UseSpaStaticFiles() method in Angular CLI based template for response caching? May be, I did it wrong, but this approach does not working and I think, problem is in UseSpaStaticFiles method:
app.UseStaticFiles(new StaticFileOptions { OnPrepareResponse = (context) => { var headers = context.Context.Response.GetTypedHeaders(); headers.CacheControl = new Microsoft.Net.Http.Headers.CacheControlHeaderValue { Public = true, MaxAge = TimeSpan.FromDays(365) }; } });

*Originally created by @ridicoulous on 12/8/2017* Hello. How about to add StaticFileOptions to UseSpaStaticFiles() method in Angular CLI based template for response caching? May be, I did it wrong, but this approach does not working and I think, problem is in UseSpaStaticFiles method: ` app.UseStaticFiles(new StaticFileOptions { OnPrepareResponse = (context) => { var headers = context.Context.Response.GetTypedHeaders(); headers.CacheControl = new Microsoft.Net.Http.Headers.CacheControlHeaderValue { Public = true, MaxAge = TimeSpan.FromDays(365) }; } }); `
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/JavaScriptServices#280
No description provided.