I am using ASP.NET MVC 4 with WEB API
I have the following action, in the action shown below, my service method makes a db call to DoMagic()
method and returns an integer value which I am then using on every page, this action is called using an ajax call.
Below is my WEB API action :
[OutputCache(Duration = 86400, VaryByParam = "none")]
[ActionName("GetMyMagicNumber")]
public int GetMyMagicNumber()
{
if (WebSecurity.IsAuthenticated)
{
var revenue = _magicService.DoMagic();
return revenue;
}
return 0;
}
My question : I haved tried using [OutputCache(Duration = 86400, VaryByParam = "none")]
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.
A db call is again made, the db call takes time how do I get this working ?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…