I've got a problem using outputcache together with urlrewriting. We've got an application that rewrites url (IE http://localhost/about/) to "~/page.aspx". Based on the URL (/about/) we figure out which content to show.
Now we're trying to add outputcache to that page:
< %@ outputcache duration="600" location="Server" varybyparam="Custom" varybycustom="RawURL" %>
And in the Global.asax we override GetVaryByCustomString like below:
public override string GetVaryByCustomString(HttpContext context, string custom)
{
if (custom == "RawUrl")
{
return context.Request.RawUrl;
}
else
{
return string.Empty;
}
}
However, when we publish the page i'd like to invalidate the cache so that the editors see the change directly. But no matter what I try, I cannot seem to invalidate the cache. If I'd like to invalidate "/about/" I would like to do this:
HttpResponse.RemoveOutputCacheItem("/about/");
That doesn't work unfortunately. The only thing that seems to work is:
HttpResponse.RemoveOutputCacheItem("/page.aspx");
This clears the cache for all my pages, not just "/about/".
Is there any way to invalidate the cache based on the url? Or should we provide a cache key or something per page to be able to invalidate the cache programmatically?
Thanks in advance!