我有以下代码
app.UseStaticFiles(new StaticFileOptions
{
OnPrepareResponse = ctx =>
{
var headers = ctx.Context.Request.GetTypedHeaders();
headers.CacheControl = new CacheControlHeaderValue
{
MaxAge = TimeSpan.FromDays(365)
};
}
});
答案 0 :(得分:0)
您需要为响应添加标头,而不是请求。变化
var headers = ctx.Context.Request.GetTypedHeaders();
到
var headers = ctx.Context.Response.GetTypedHeaders();