I wrote some VB code for an AppFabricOutputCacheProvider in January - it's on my blog here. A C# (4.0) version would be:
using System.Web;
using Microsoft.ApplicationServer.Caching;
namespace AppFabricOutputCache
{
public class CacheProvider: System.Web.Caching.OutputCacheProvider, IDisposable
{
DataCache mCache;
const String OutputCacheName = "OutputCache";
public void New()
{
DataCacheFactory factory;
factory = new DataCacheFactory();
mCache = factory.GetCache(OutputCacheName);
}
public override Object Add(String key, Object entry, DateTime utcExpiry)
{
mCache.Add(key, entry, utcExpiry - DateTime.UtcNow);
return entry;
}
public override object Get(string key)
{
return mCache.Get(key);
}
public override void Remove(string key)
{
mCache.Remove(key);
}
public override void Set(string key, object entry, DateTime utcExpiry)
{
mCache.Put(key, entry, utcExpiry - DateTime.UtcNow);
}
public void IDisposable.Dispose()
{
mCache = null;
}
}
}
To use this in your application, you need this in your web.config.
<caching>
<outputCache>
<providers>
<add name="AppFabricOutputCacheProvider" type="AppFabricOutputCache.CacheProvider"/>
</providers>
</outputCache>
</caching>
Gunnar Peipman has a disk-based output cache provider on his blog here.