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(" {<br/>"); first = false; } else { sb.Append(",<br/> {<br/>"); } sb.Append(" \"category\":\"" + rule.CategoryName + "\",<br/>"); sb.Append(" \"priority\":\"" + rule.Priority + "\",<br/>"); sb.Append(" \"cacheCategory\":\"" + rule.CacheCategory + "\",<br/>"); sb.Append(" \"serverCacheTime\":\"" + rule.ServerCacheTime + "\",<br/>"); sb.Append(" \"browserCacheTime\":\"" + rule.BrowserCacheTime + "\"<br/>"); sb.Append(" }"); } 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; }