Hi, I am trying to implement Response Caching in MVC 6 but it doesn't work. Here are two scenarioes.
Scenario 1:
Index.cshtml page:
<cache expires-after="@TimeSpan.FromSeconds(10)">
@DateTime.Now.ToString();
</cache>
HomeController:
public IActionResult Index()
{
DateTime t = DateTime.Now;
return View(t);
}
at Index.cshtml and call this from Index action method then it works fine and it takes 10 ms to refresh time.
But when I tried to call this Index.cshtml view from in Index action using [ResponseCache()] it doesn't work.
[ResponseCache(Duration =10)]
public IActionResult Index()
{
DateTime t = DateTime.Now;
return View(t);
}