C# Asp.net core 2.2响应缓存,无法将必须重新验证添加到缓存控制响应头

C# Asp.net core 2.2响应缓存,无法将必须重新验证添加到缓存控制响应头,c#,asp.net-core,responsecache,C#,Asp.net Core,Responsecache,我使用以下设置进行响应缓存: services.AddMvc(options => { options.CacheProfiles.Add("HomePage", new CacheProfile() { Duration = Constants.HomePageOutputCacheInSeconds,

我使用以下设置进行响应缓存:

 services.AddMvc(options =>
            {
                
                options.CacheProfiles.Add("HomePage", new CacheProfile()
                {
                    Duration = Constants.HomePageOutputCacheInSeconds,
                    Location = ResponseCacheLocation.Any,
                    VaryByHeader = HttpCacheProfileProvider.CacheKeyHeader

                });
                options.CacheProfiles.Add("Article", new CacheProfile()
                {
                    Duration = Constants.ArticleOutputCacheInSeconds,
                    Location = ResponseCacheLocation.Any,
                    VaryByHeader = HttpCacheProfileProvider.CacheKeyHeader
                });
                options.CacheProfiles.Add("Default", new CacheProfile()
                {
                    Duration = Constants.DefaultOutputCacheInSeconds,
                    Location = ResponseCacheLocation.Any,
                    VaryByHeader = HttpCacheProfileProvider.CacheKeyHeader
                });

                


            }).SetCompatibilityVersion(Microsoft.AspNetCore.Mvc.CompatibilityVersion.Version_2_2);

services.AddMemoryCache();
services.AddResponseCaching();
在配置部分,我设置:

 app.UseResponseCaching();
和控制器:

[Route("", Name = "DesktopHome")]
[ResponseCache(CacheProfileName = "HomePage", Order = int.MaxValue)]
public async Task<IActionResult> Index()
[路由(“,Name=“DesktopHome”)]
[响应缓存(CacheProfileName=“HomePage”,Order=int.MaxValue)]
公共异步任务索引()
一切正常<代码>缓存控制:公共,最大年龄:10附加在标题中,但我想设置必须重新验证和最大过时缓存属性,我找不到属性来完成此操作

属性在CacheProfiles设置、ResponseCacheAttribute或app.UserResponseCaching设置中不可用


这可能吗?

除了在Cacheprofile中设置外,您还可以直接使用Response来设置它们:

    public async Task<IActionResult> Index()
    {
        Response.GetTypedHeaders().CacheControl = new CacheControlHeaderValue()
        {
            Public = true,
            MaxAge = TimeSpan.FromSeconds(600),
            MustRevalidate = true,
            MaxStale = true
        };

        return View();
    }
公共异步任务索引()
{
Response.GetTypedHeaders().CacheControl=new CacheControlHeaderValue()
{
公共=真实,
最大年龄=从秒开始的时间跨度(600),
MustRevalidate=true,
MaxStale=true
};
返回视图();
}


或者您可以登录官方网站。

缓存配置文件中没有可用的属性