-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Description
I have a Asp.Net Core Mvc 9.0 web application. My simple config is as below:
...
builder.Services.AddControllersWithViews(options =>
{
options.Filters.Add(new AutoValidateAntiforgeryTokenAttribute());
options.CacheProfiles.Add(ResponseCacheProfileNameConsts.Duration1HourProfile, new CacheProfile
{
Duration = 60 * 60,
Location = ResponseCacheLocation.Any
});
}).AddViewLocalization();
...
app.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}")
.WithStaticAssets();
app.Run();
No response cache middleware, I am just using ResponseCacheAttribute.
And my HomeController
looks like as below:
[ResponseCache(CacheProfileName = ResponseCacheProfileNameConsts.Duration1HourProfile)]
public IActionResult Index()
{
return View();
}
I always have a cache miss (caching behavior does not work), and Console warning saying: warn: Microsoft.AspNetCore.Antiforgery.DefaultAntiforgery[8] The 'Cache-Control' and 'Pragma' headers have been overridden and set to 'no-cache, no-store' and 'no-cache' respectively to prevent caching of this response. Any response that uses antiforgery should not be cached.
I did not open this issue as a bug, because of I can not reproduce it in new and clean project with very same config. It used to work previously (until a few days ago), the cache behaviour used to work, recently I did notice it, it gives warning in the console and cache does not work.
What could be the reason?
Thank in advance.