The following C# code sample is a simple console program that can delete all contents of the cache, or delete a specific URL that you wish to clear from the cache.
In order for this to compile, you will need to reference the Microsoft.Web.Administration DLL which I found in the GAC (though I also believe it is part of the Windows SDK as well).
using Microsoft.Web.Administration;
using System;
namespace IISCacheManager
{
class Program
{
static void Main(string[] args)
{
if (args.Length != 1)
{
Console.WriteLine("Incorrect Usage: Specify the URL that you want to flush the cache for. To delete everything, specify 'ALL'.");
Environment.Exit(1);
}
var url = args[0] == "ALL" ? string.Empty : args[0];
var m = new ServerManager();
var x = m.GetApplicationHostConfiguration().GetSection("system.webServer/diskCache");
var method = x.Methods["FlushUrl"].CreateInstance();
method.Input.SetAttributeValue("url", url);
method.Execute();
Console.WriteLine("Item flushed successfully.");
}
}
}
Hope this helps!