Reputation: 1126
I want to cache the home page in the client browser
But after setting the ResponseCache attribute, the response header is set to Cache-Control: no-cache, no-store
After reading Response cache not working in asp.net core project and ResponseCache not working in net core 3.1 I can't fix this
[ResponseCache(Duration = 300)]
public class HomeModel : PageModel
{
public const string PageName = "Home";
public void OnGet()
{
}
}
Upvotes: 4
Views: 3095
Reputation: 1126
Because I add a form in _layout.cshtml for search field an anti forgery token generated in it automatically!
ASP.net core set Cache-Control: no-cache, no-store for each page which contains an anti forgery field or has Authorize attribute!
By moving this form from the _layout.cshtml, problem resolved!
Upvotes: 9
Reputation: 1126
Because I add a form in _layout.cshtml for search field an anti forgery token generated in it automatically!
ASP.net core set Cache-Control: no-cache, no-store for each page which contains an anti forgery field!
By moving this form from the _layout.cshtml, problem resolved!
Upvotes: -1