private Task DocumentConfiguration(IOwinContext context)
        {
            Func <IEnumerable <OutputCacheRule>, string> formatRules = (rules) =>
            {
                var sb = new StringBuilder();
                sb.Append("<pre>[<br/>");
                var first = true;
                foreach (var rule in rules)
                {
                    if (first)
                    {
                        sb.Append("&nbsp;&nbsp;{<br/>");
                        first = false;
                    }
                    else
                    {
                        sb.Append(",<br/>&nbsp;&nbsp;{<br/>");
                    }
                    sb.Append("&nbsp;&nbsp;&nbsp;&nbsp;\"category\":\"" + rule.CategoryName + "\",<br/>");
                    sb.Append("&nbsp;&nbsp;&nbsp;&nbsp;\"priority\":\"" + rule.Priority + "\",<br/>");
                    sb.Append("&nbsp;&nbsp;&nbsp;&nbsp;\"cacheCategory\":\"" + rule.CacheCategory + "\",<br/>");
                    sb.Append("&nbsp;&nbsp;&nbsp;&nbsp;\"serverCacheTime\":\"" + rule.ServerCacheTime + "\",<br/>");
                    sb.Append("&nbsp;&nbsp;&nbsp;&nbsp;\"browserCacheTime\":\"" + rule.BrowserCacheTime + "\"<br/>");
                    sb.Append("&nbsp;&nbsp;}");
                }
                sb.Append("<br/>]</pre>");
                return(sb.ToString());
            };

            var document = GetEmbeddedResource("configuration.html");

            document = document.Replace("{rules}", formatRules(_configuration.Rules));
            document = document.Replace("{documentationUrl}", _configuration.DocumentationRootUrl);

            var defaultConfiguration = new OutputCacheConfiguration();

            document = document.Replace("{rules.default}", formatRules(defaultConfiguration.Rules));
            document = document.Replace("{documentationUrl.default}", defaultConfiguration.DocumentationRootUrl);

            context.Response.ContentType = "text/html";
            return(context.Response.WriteAsync(document));
        }
            public OutputCacheContext(
                ICache cache,
                IOwinContext context,
                OutputCacheConfiguration configuration)
            {
                _cache         = cache;
                _context       = context;
                _configuration = configuration;

                _cacheKey       = GetCacheKey(context);
                _cachedResponse = cache.Get <CachedResponse>(_cacheKey);
                if (_cachedResponse != null)
                {
                    TimeInCache      = DateTime.UtcNow - _cachedResponse.WhenCached;
                    UseCachedContent = true;
                }

                MaximumCacheTime = TimeSpan.FromHours(1);
                Category         = "None";
                Priority         = CachePriority.Never;
            }
 private void ConfigurationChanged(OutputCacheConfiguration configuration)
 {
     _configuration = configuration;
 }