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