问题
I am using an OutputCache Profile to cache on the server some json data.
[HttpGet]
[OutputCache(CacheProfile = "1HourCacheProfile")]
public JsonResult GetBranches()
{
var result = mMapper.Map<List<IntItem>>(mConfigurationServices.GetBranches());
return Json(new { list = result }, JsonRequestBehavior.AllowGet);
}
The profile is registered in Web.config as below
I want to hook somehow a refresh logic on this cached output on different actions that are updating my source. I have found some solution where I can remove an action from the cache with something like below, but I was wondering if there is a way to use some type of filter to refresh all the cached items of my profile.
// Get the url for the action method:
var staleItem = Url.Action("Action", "YourController", new
{
Id = model.Id,
area = "areaname";
});
// Remove the item from cache
Response.RemoveOutputCacheItem(staleItem);
来源:https://stackoverflow.com/questions/64976253/refresh-outputcache-profile-on-demand