Wednesday, 15 June 2011

c# - How to use caching in ASP.NET Web API? -



c# - How to use caching in ASP.NET Web API? -

i using asp.net mvc 4 web api

i have next action, in action shown below, service method makes db phone call domagic() method , returns integer value using on every page, action called using ajax call.

below web api action :

[outputcache(duration = 86400, varybyparam = "none")] [actionname("getmymagicnumber")] public int getmymagicnumber() { if (websecurity.isauthenticated) { var revenue = _magicservice.domagic(); homecoming revenue; } homecoming 0; }

my question : haved tried using [outputcache(duration = 86400, varybyparam = "none")] , excepted first time db phone call made , next subsequent request action homecoming me cached value, not happening.

a db phone call 1 time again made, db phone call takes time how working ?

unfortunately, caching not built asp.net web api.

check out on track: http://www.strathweb.com/2012/05/output-caching-in-asp-net-web-api/

an updated resource here: https://github.com/filipw/aspnetwebapi-outputcache

c# asp.net-web-api http-caching

No comments:

Post a Comment