public void Apply(HttpCachePolicyBase policy) { policy.ThrowIfNull("policy"); if (!_hasPolicy) { return; } switch (_cacheability) { case HttpCacheability.NoCache: policy.SetCacheability(_allowsServerCaching == true ? HttpCacheability.ServerAndNoCache : HttpCacheability.NoCache); break; case HttpCacheability.Private: policy.SetCacheability(_allowsServerCaching == true ? HttpCacheability.ServerAndPrivate : HttpCacheability.Private); break; case HttpCacheability.Public: policy.SetCacheability(HttpCacheability.Public); break; } if (_noStore == true) { policy.SetNoStore(); } if (_noTransforms == true) { policy.SetNoTransforms(); } if (_clientCacheExpirationUtcTimestamp != null) { policy.SetExpires(_clientCacheExpirationUtcTimestamp.Value); } if (_clientCacheMaxAge != null) { policy.SetMaxAge(_clientCacheMaxAge.Value); } if (_allowResponseInBrowserHistory != null) { policy.SetAllowResponseInBrowserHistory(_allowResponseInBrowserHistory.Value); } if (_eTag != null) { policy.SetETag(_eTag); } if (_omitVaryStar != null) { policy.SetOmitVaryStar(_omitVaryStar.Value); } if (_proxyMaxAge != null) { policy.SetProxyMaxAge(_proxyMaxAge.Value); } if (_revalidation != null) { policy.SetRevalidation(_revalidation.Value); } }
public override void OnResultExecuted(ResultExecutedContext filterContext) { HttpCachePolicyBase cache = filterContext.HttpContext.Response.Cache; cache.SetCacheability(HttpCacheability.NoCache); cache.SetNoStore(); base.OnResultExecuted(filterContext); }
private static void InvalidateCache(HttpCachePolicyBase cache) { cache.SetExpires(DateTime.UtcNow.AddDays(-1)); cache.SetValidUntilExpires(false); cache.SetRevalidation(HttpCacheRevalidation.AllCaches); cache.SetCacheability(HttpCacheability.NoCache); cache.SetNoStore(); }
public override void OnActionExecuted(ActionExecutedContext filterContext) { HttpCachePolicyBase cache = filterContext.HttpContext.Response.Cache; cache.SetCacheability(HttpCacheability.NoCache); cache.SetExpires(DateTime.Now); cache.SetAllowResponseInBrowserHistory(false); cache.SetNoServerCaching(); cache.SetNoStore(); }
private void AddNoOutputCacheHeaders(AuthorizationContext filterContext) { HttpCachePolicyBase cachePolicy = filterContext.HttpContext.Response.Cache; cachePolicy.SetExpires(DateTime.UtcNow.AddDays(-1)); cachePolicy.SetValidUntilExpires(false); cachePolicy.AppendCacheExtension("must-revalidate, proxy-revalidate"); cachePolicy.SetCacheability(HttpCacheability.NoCache); cachePolicy.SetNoStore(); }
public override void OnResultExecuted(ResultExecutedContext filterContext) { if (filterContext.HttpContext.Request.IsAjaxRequest()) { HttpCachePolicyBase cache = filterContext.HttpContext.Response.Cache; cache.SetExpires(DateTime.UtcNow.AddDays(-1)); cache.SetCacheability(HttpCacheability.NoCache); cache.SetNoStore(); } }
public override void OnActionExecuted(ActionExecutedContext filterContext) { HttpCachePolicyBase cache = filterContext.HttpContext.Response.Cache; cache.SetExpires(DateTime.UtcNow.AddDays(-1)); cache.SetValidUntilExpires(false); cache.SetRevalidation(HttpCacheRevalidation.AllCaches); cache.SetCacheability(HttpCacheability.NoCache); cache.SetNoStore(); }
public override void OnResultExecuted(ResultExecutedContext filterContext) { HttpCachePolicyBase cache = filterContext.HttpContext.Response.Cache; cache.SetCacheability(HttpCacheability.NoCache); cache.SetCacheability(HttpCacheability.NoCache); cache.SetExpires(DateTime.UtcNow.AddHours(-1)); cache.SetNoStore(); base.OnResultExecuted(filterContext); }
public new void OnResultExecuted(ResultExecutedContext filterContext) { HttpCachePolicyBase cache = filterContext.HttpContext.Response.Cache; cache.SetCacheability(HttpCacheability.NoCache); cache.SetRevalidation(HttpCacheRevalidation.AllCaches); cache.SetValidUntilExpires(false); cache.SetExpires(DateTime.UtcNow.AddDays(-1)); cache.SetNoStore(); cache.AppendCacheExtension("private"); cache.AppendCacheExtension("no-cache=Set-Cookie"); cache.SetProxyMaxAge(TimeSpan.Zero); }
public override void OnActionExecuted(ActionExecutedContext filterContext) { if (Duration <= 0) { return; } HttpCachePolicyBase cache = filterContext.HttpContext.Response.Cache; TimeSpan cacheDuration = TimeSpan.FromSeconds(Duration); cache.SetNoStore(); cache.SetCacheability(HttpCacheability.NoCache); cache.SetRevalidation(HttpCacheRevalidation.AllCaches); cache.AppendCacheExtension("post-check=0, pre-check=0"); //cache.SetVaryByCustom("lang"); //cache.SetExpires(DateTime.Now.Add(cacheDuration)); //cache.SetMaxAge(cacheDuration); }
public override void OnResultExecuting(ResultExecutingContext filterContext) { if (filterContext.IsChildAction) { return; } HttpCachePolicyBase cachePolicy = filterContext.HttpContext.Response.Cache; cachePolicy.SetExpires(DateTime.UtcNow.AddDays(-1)); cachePolicy.SetValidUntilExpires(false); //cachePolicy.SetRevalidation(HttpCacheRevalidation.AllCaches); cachePolicy.AppendCacheExtension("must-revalidate, proxy-revalidate"); cachePolicy.SetCacheability(HttpCacheability.NoCache); cachePolicy.SetNoStore(); base.OnResultExecuting(filterContext); }
public void ProcessRequest(HttpContextBase context) { this._context = context; HttpRequestBase request = context.Request; HttpResponseBase response = context.Response; Uri url = request.Url; string str = !(url == (Uri)null) ? url.LocalPath : throw new HttpException(500, BundleTransformer.Core.Resources.Strings.Common_ValueIsNull); if (string.IsNullOrWhiteSpace(str)) { throw new HttpException(500, BundleTransformer.Core.Resources.Strings.Common_ValueIsEmpty); } if (!this._virtualFileSystemWrapper.FileExists(str)) { throw new HttpException(404, string.Format(BundleTransformer.Core.Resources.Strings.Common_FileNotExist, (object)str)); } string bundleVirtualPath = request.QueryString[Common.BundleVirtualPathQueryStringParameterName]; if (string.IsNullOrWhiteSpace(bundleVirtualPath) && this.IsStaticAsset) { AssetHandlerBase.ProcessStaticAssetRequest(context); } else { string processedAssetContent; try { processedAssetContent = this.GetProcessedAssetContent(str, bundleVirtualPath); } catch (HttpException ex) { throw; } catch (AssetTranslationException ex) { throw new HttpException(500, ex.Message, (Exception)ex); } catch (AssetPostProcessingException ex) { throw new HttpException(500, ex.Message, (Exception)ex); } catch (FileNotFoundException ex) { throw new HttpException(500, string.Format(BundleTransformer.Core.Resources.Strings.AssetHandler_DependencyNotFound, (object)ex.Message, (object)ex)); } catch (Exception ex) { throw new HttpException(500, string.Format(BundleTransformer.Core.Resources.Strings.AssetHandler_UnknownError, (object)ex.Message, (object)ex)); } HttpCachePolicyBase cache = response.Cache; if (this._assetHandlerConfig.DisableClientCache) { response.StatusCode = 200; response.StatusDescription = "OK"; cache.SetCacheability(HttpCacheability.NoCache); cache.SetExpires(DateTime.UtcNow.AddYears(-1)); cache.SetValidUntilExpires(false); cache.SetNoStore(); cache.SetNoServerCaching(); response.ContentType = this.ContentType; response.Write(processedAssetContent); } else { string assetEtag = AssetHandlerBase.GenerateAssetETag(processedAssetContent); int num = AssetHandlerBase.IsETagHeaderChanged(request, assetEtag) ? 1 : 0; if (num != 0) { response.StatusCode = 200; response.StatusDescription = "OK"; } else { response.StatusCode = 304; response.StatusDescription = "Not Modified"; response.AddHeader("Content-Length", "0"); } response.AddHeader("X-Asset-Transformation-Powered-By", "Bundle Transformer"); cache.SetCacheability(HttpCacheability.Public); cache.SetExpires(DateTime.UtcNow.AddYears(-1)); cache.SetValidUntilExpires(true); cache.AppendCacheExtension("must-revalidate"); cache.SetNoServerCaching(); cache.VaryByHeaders["If-None-Match"] = true; cache.SetETag(assetEtag); if (num != 0) { response.ContentType = this.ContentType; response.Write(processedAssetContent); } } context.ApplicationInstance.CompleteRequest(); } }