问题
I have an app that runs on Azure Web Worker Roles and is using the Co-Located Role Cache as the default output cache.
I also use a varybycustom so that I can partial cache a page with cachable areas.
So in my home page I have this:
<div id="collectionsheader">
@Html.Action("Header", new{ controller = "Collections", area="Dam" })
</div>
which refers to this action:
[OutputCache(Duration = 3600, VaryByCustom = "host")]
public ActionResult Header()
{
...
}
the varybycustom is so that in this multitenant app the cached output is changed for each subdomain which accesses the app. This is in the Global.ascx:
public override string GetVaryByCustomString(HttpContext context, string arg)
{
if (arg == "host")
{
return context.Request.Headers["host"];
}
}
So here is the question How do I evict this content per domain when I need to force a refresh of this item.
Currently I am doing this:
var urlToRemove = url.Action("Header", "Collections");
if (urlToRemove != null) HttpResponse.RemoveOutputCacheItem(urlToRemove);
But this is not working, and I am sure it's because of the VaryByCustom key.
Can anyone shed any light on to how I would evict this cached content when I need to?
Thanks in advance.
来源:https://stackoverflow.com/questions/20288600/how-to-evict-from-output-cache-when-using-varybycustom-for-multitenant-app