title: Caching full response on the server
body: <p>Here's a very small sample Razor Page:</p>
  
  <pre><code>@page
  @model IndexModel
  @{
      ViewData["Title"] = "Home page";
  }
  
  &lt;h1&gt;
      @DateTime.Now.ToString()
  &lt;/h1&gt;
  
  //model
  public class IndexModel : PageModel
  {
      private readonly ILogger&lt;IndexModel&gt; _logger;
  
      public IndexModel(ILogger&lt;IndexModel&gt; logger)
      {
          _logger = logger;
      }
  
      public void OnGet()
      {
  
      }
  }
  </code></pre>
  
  <p>If I use this code, the time will update every 30 seconds which is what is intended:</p>
  
  <pre><code>&lt;cache expires-after="TimeSpan.FromSeconds(30)"&gt;
      &lt;h1&gt;
          @DateTime.Now.ToString()
      &lt;/h1&gt;
  &lt;/cache&gt;
  </code></pre>
  
  <p>However, adding the <code>ResponseCache</code> attribute to the model doesn't do this:</p>
  
  <pre><code>[ResponseCache(Duration = 30)]
  public class IndexModel : PageModel
  </code></pre>
  
  <p>After doing some research it seems like the attribute only sends the appropriate headers to the client, asking it to cache the content. How can I store the entire response in memory so when the user asks for the specific page, the server just sends the cached response and eliminate the process of computing the result again?</p>
  
  <p>Also, with the <code>&lt;cache&gt;</code> tag helper, I couldn't find a way to invalidate the cached entry. So one scenario for me would be to cache every single page in memory for 30 days and if I change something on the admin panel, I would then invalidate the cache for that specific item so the next request would produce the fresh result. I used to do this on Asp.Net MVC 3+ but couldn't find any method to achieve the same result in Asp.Net Core 3.1</p>