Reputation: 380
I made a controller action in my asp.net web API MVC 4 and since its running was long i cached its output for 5 mins. Then made a .NET client to consume this API. Now i want that before cache expires action should be called again automatically in web API. So that every time its the cached output that the client gets. How to do that?
Is it possible to call a controller action from web API itself so that it gets cached every time or i would have to do it in ASP.NET client?
here is the action from web api. To cache result on server i am using Strathweb.CacheOutput 0.5.0
package
[System.Web.Http.HttpGet]
[CacheOutput(ClientTimeSpan = 300, ServerTimeSpan = 300)]
public HttpResponseMessage givedisabledusers()
{
var result = dbh.givedisabledusers();
return Request.CreateResponse(HttpStatusCode.OK, result);
}
Upvotes: 3
Views: 1532
Reputation: 6246
There is no such mechanism where the output cache refreshes itself automatically after expiration. One solution would be to a create a worker process or background job that automatically 'pings' the API endpoint after a certain duration (in your case, perhaps every 4.5 minutes instead of 5 to allow for the db call/processing of givedisabledusers()
).
Upvotes: 1