ASP.NET caching helper
Several suggestions:


You could use MemoryCache class as of .NET 4, which would free you from System.Web assembly.
You should use lock in order to put the value to cache.
You should take care of value types objects


So, here is the code:

public static T GetCached&lt;T&gt;(string key, Func&lt;T&gt; initializer, TimeSpan slidingExpiration, DateTime absoluteExpiration)
{
    var httpContext = HttpContext.Current;

    if (httpContext != null)
    {
        key = string.Intern(key); 
        lock(key) // locking on interned key
        {
            var obj = httpContext.Cache[key];
            if (obj == null)
            {
                obj = initializer();
                httpContext.Cache.Add(key, obj, null, absoluteExpiration, slidingExpiration, System.Web.Caching.CacheItemPriority.Default, null);
            }
            // taking care of value types
            if (obj == null &amp;&amp; (typeof (T)).IsValueType)
            {
                return default(T);
            }
            return (T)obj;
        }
    }
    else
    {
        return initializer(); // no available cache
    }
}