title: How to use caching in ASP.NET Web API?
body: <p>I am using ASP.NET MVC 4 with WEB API</p>
  
  <p>I have the following action, in the action shown below, my service method makes a db call to <code>DoMagic()</code> method and returns an integer value which I am then using on every page, this action is called using an ajax call. </p>
  
  <p>Below is my WEB API action : </p>
  
  <pre><code>[OutputCache(Duration = 86400, VaryByParam = "none")]
  [ActionName("GetMyMagicNumber")]
  public int GetMyMagicNumber()
  {
      if (WebSecurity.IsAuthenticated)
      {
          var revenue = _magicService.DoMagic();
          return revenue;
      }
      return 0;
  }
  </code></pre>
  
  <p>My question : I haved tried using <code>[OutputCache(Duration = 86400, VaryByParam = "none")]</code> and I excepted that only the first time the db call will be made and next subsequent request to this action will return me the cached value, but this is not happening. </p>
  
  <p>A db call is again made, the db call takes time how do I get this working ?</p>