/// <summary> /// Configures ASP.Net's Cache policy based on properties set /// </summary> /// <param name="policy">cache policy to set</param> void ICachePolicyConfigurer.Configure(HttpCachePolicy policy) { policy.SetAllowResponseInBrowserHistory(allowInHistory); policy.SetCacheability(cacheability); policy.SetOmitVaryStar(omitVaryStar); policy.SetRevalidation(revalidation); policy.SetSlidingExpiration(slidingExpiration); policy.SetValidUntilExpires(validUntilExpires); if (duration != 0) { policy.SetExpires(DateTime.Now.AddSeconds(duration)); } if (varyByContentEncodings != null) { foreach (var header in varyByContentEncodings.Split(',')) { policy.VaryByContentEncodings[header.Trim()] = true; } } if (varyByCustom != null) { policy.SetVaryByCustom(varyByCustom); } if (varyByHeaders != null) { foreach (var header in varyByHeaders.Split(',')) { policy.VaryByHeaders[header.Trim()] = true; } } if (varyByParams != null) { foreach (var param in varyByParams.Split(',')) { policy.VaryByParams[param.Trim()] = true; } } if (cacheExtension != null) { policy.AppendCacheExtension(cacheExtension); } if (setEtagFromFileDependencies) { policy.SetETagFromFileDependencies(); } if (setLastModifiedFromFileDependencies) { policy.SetLastModifiedFromFileDependencies(); } if (setNoServerCaching) { policy.SetNoServerCaching(); } if (setNoStore) { policy.SetNoStore(); } if (setNoTransforms) { policy.SetNoTransforms(); } if (etag != null) { policy.SetETag(etag); } if (isLastModifiedSet) { policy.SetLastModified(lastModified); } if (isMaxAgeSet) { policy.SetMaxAge(TimeSpan.FromSeconds(maxAge)); } if (isProxyMaxAgeSet) { policy.SetProxyMaxAge(TimeSpan.FromSeconds(proxyMaxAge)); } }
/// <summary> /// Set the response cache headers for WebResource /// </summary> /// <param name="cache"></param> /// <param name="etag"></param> private static void SetCachingHeadersForWebResource(HttpCachePolicy cache, int etag) { cache.VaryByParams["d"] = true; cache.VaryByHeaders["Accept-Encoding"] = true; cache.SetOmitVaryStar(true); // Keep in the client cache for the time configured in the Web.Config cache.SetExpires(DateTime.UtcNow.AddDays(Settings.Instance.DaysInCache)); cache.SetMaxAge(TimeSpan.FromDays(Settings.Instance.DaysInCache)); cache.SetValidUntilExpires(true); cache.SetLastModified(DateTime.UtcNow); cache.SetCacheability(HttpCacheability.Public); cache.SetETag(string.Concat("\"", etag, "\"")); }
/// <summary> /// Set the response cache headers for WebResource /// </summary> /// <param name="cache"></param> /// <param name="etag"></param> /// <param name="maxAge"></param> protected static void SetCachingHeadersForWebResource(HttpCachePolicy cache, string etag, TimeSpan maxAge) { cache.SetCacheability(HttpCacheability.Public); cache.VaryByParams["d"] = true; cache.SetOmitVaryStar(true); cache.SetExpires(DateTime.Now.Add(maxAge)); cache.SetValidUntilExpires(true); cache.VaryByHeaders["Accept-Encoding"] = true; cache.SetETag(string.Concat("\"", etag, "\"")); }
public override void SetETag(string etag) { _httpCachePolicy.SetETag(etag); }
public override void SetETag(string etag) { w.SetETag(etag); }
/// <summary> /// Configures ASP.Net's Cache policy based on properties set /// </summary> /// <param name="policy">cache policy to set</param> void ICachePolicyConfigurer.Configure(HttpCachePolicy policy) { policy.SetCacheability(cacheability); policy.SetSlidingExpiration(slidingExpiration); policy.SetValidUntilExpires(validUntilExpires); policy.SetAllowResponseInBrowserHistory(allowInHistory); if (duration != 0) { policy.SetExpires(DateTime.Now.AddSeconds(duration)); } if (varyByCustom != null) { policy.SetVaryByCustom(varyByCustom); } if (varyByHeaders != null) { foreach(String header in varyByHeaders.Split(',')) { policy.VaryByHeaders[header.Trim()] = true; } } if (varyByParams != null) { foreach(String param in varyByParams.Split(',')) { policy.VaryByParams[param.Trim()] = true; } } if (etag != null) { policy.SetETag(etag); } }