title: How to cache data from repository call
body: <p>I am working in a multi-layered web application that has ASP.NET MVC as its front-end client. A particular page of this web application is taking a very long time to load. Around 30 seconds.</p>
  
  <p>I downloaded <a href="https://www.jetbrains.com/profiler/" rel="nofollow noreferrer">dotTrace</a> and ran it on my application (following <a href="https://www.youtube.com/watch?v=DxOWaRkFSMM" rel="nofollow noreferrer">this tutorial</a>). I found out that the reason my application is slow.</p>
  
  <p>It turns out it is because one particular method that I have does a load of work (takes time), and that same method gets called a total of 4 times.</p>
  
  <p>Here is a screenshot from dotTrace showing the above:</p>
  
  <p><img src="https://i.stack.imgur.com/DcKnd.png" alt="dotTrace screenshot"></p>
  
  <p>The method in question is <code>GetTasks()</code>. So in order to improve the speed of the web application I want to <strong>cache the data returned from <code>GetTasks()</code></strong> for each request.</p>
  
  <p>If my thinking is correct, this would really improve on the speed issues I am having.</p>
  
  <p>My question is, how can I achieve this? I have never done such a thing before. For each new request, how can I cache the data returned from <code>GetTasks()</code>, and use that for all subsequent calls to <code>GetTasks()</code>.</p>