The Free Software Media System - Server Backend & API
update caching headers
Luke Pulverenti6c0743a70dfa
diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs b/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.csindex 080441dda4..4252d7aa82 100644--- a/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs+++ b/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs@@ -114,6 +114,12 @@ namespace MediaBrowser.Server.Implementations.HttpServer/// <exception cref="System.ArgumentNullException">result</exception>public object GetOptimizedResult<T>(IRequest requestContext, T result, IDictionary<string, string> responseHeaders = null)where T : class+ {+ return GetOptimizedResultInternal<T>(requestContext, result, true, responseHeaders);+ }++ private object GetOptimizedResultInternal<T>(IRequest requestContext, T result, bool addCachePrevention, IDictionary<string, string> responseHeaders = null)+ where T : class{if (result == null){@@ -122,20 +128,27 @@ namespace MediaBrowser.Server.Implementations.HttpServervar optimizedResult = requestContext.ToOptimizedResult(result);- if (responseHeaders != null)+ if (responseHeaders == null){- // Apply headers- var hasOptions = optimizedResult as IHasOptions;+ responseHeaders = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);+ }- if (hasOptions != null)- {- AddResponseHeaders(hasOptions, responseHeaders);- }+ if (addCachePrevention)+ {+ responseHeaders["Expires"] = "-1";+ }++ // Apply headers+ var hasOptions = optimizedResult as IHasOptions;++ if (hasOptions != null)+ {+ AddResponseHeaders(hasOptions, responseHeaders);}return optimizedResult;}-+/// <summary>/// Gets the optimized result using cache./// </summary>@@ -166,7 +179,7 @@ namespace MediaBrowser.Server.Implementations.HttpServerif (responseHeaders == null){- responseHeaders = new Dictionary<string, string>();+ responseHeaders = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);}// See if the result is already cached in the browser@@ -177,7 +190,7 @@ namespace MediaBrowser.Server.Implementations.HttpServerreturn result;}- return GetOptimizedResult(requestContext, factoryFn(), responseHeaders);+ return GetOptimizedResultInternal(requestContext, factoryFn(), false, responseHeaders);}/// <summary>@@ -209,7 +222,7 @@ namespace MediaBrowser.Server.Implementations.HttpServerif (responseHeaders == null){- responseHeaders = new Dictionary<string, string>();+ responseHeaders = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);}// See if the result is already cached in the browser@@ -363,7 +376,7 @@ namespace MediaBrowser.Server.Implementations.HttpServerpublic object GetStaticResult(IRequest requestContext, StaticResultOptions options){var cacheKey = options.CacheKey;- options.ResponseHeaders = options.ResponseHeaders ?? new Dictionary<string, string>();+ options.ResponseHeaders = options.ResponseHeaders ?? new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);var contentType = options.ContentType;if (cacheKey == Guid.Empty)