internal void OnUpdateRequestCache(EdgeCacheEventArgs e) { foreach (EdgeCacheRule rule in _rules) { rule.OnUpdateRequestCache(e); } }
internal void OnPostMapRequestHandler(EdgeCacheEventArgs e) { foreach (EdgeCacheRule rule in _rules) { rule.OnPostMapRequestHandler(e); } }
internal void OnPreSendRequestHeaders(EdgeCacheEventArgs e) { foreach (EdgeCacheRule rule in _rules) { rule.OnPreSendRequestHeaders(e); } }
internal void OnPostAuthorizeRequest(EdgeCacheEventArgs e) { foreach (EdgeCacheRule rule in _rules) { rule.OnPostAuthorizeRequest(e); } }
internal void OnUpdateRequestCache(EdgeCacheEventArgs e) { if (UpdateRequestCache != null) { if (IncludeUrl(e.Context)) { UpdateRequestCache(this, e); } } }
internal void OnPreSendRequestHeaders(EdgeCacheEventArgs e) { if (PreSendRequestHeaders != null) { if (IncludeUrl(e.Context)) { PreSendRequestHeaders(this, e); } } }
internal void OnResolveRequestCache(EdgeCacheEventArgs e) { if (ResolveRequestCache != null) { if (IncludeUrl(e.Context)) { ResolveRequestCache(this, e); } } }
internal void OnPostMapRequestHandler(EdgeCacheEventArgs e) { if (PostMapRequestHandler != null) { if (IncludeUrl(e.Context)) { PostMapRequestHandler(this, e); } } }
internal void OnPostAuthorizeRequest(EdgeCacheEventArgs e) { if (PostAuthorizeRequest != null) { if (IncludeUrl(e.Context)) { PostAuthorizeRequest(this, e); } } }
private void OnPreSendRequestHeaders(object sender, EdgeCacheEventArgs e) { EdgeCacheRule rule = (EdgeCacheRule)sender; HttpContext context = e.Context; int minutes = rule.Duration; HttpResponse response = context.Response; HttpCachePolicy policy = response.Cache; policy.SetMaxAge(TimeSpan.FromMinutes(minutes)); policy.SetCacheability(HttpCacheability.ServerAndPrivate); policy.SetSlidingExpiration(true); }
private void OnUpdateRequestCache(object sender, EdgeCacheEventArgs e) { EdgeCacheRule rule = (EdgeCacheRule)sender; HttpContext context = e.Context; HttpResponse response = context.Response; HttpRequest request = context.Request; OutputCacheKeyBuilder keyBuilder = new OutputCacheKeyBuilder(context); if (response.StatusCode != 200) { return; } DynamicInvoke invoker = new DynamicInvoke(response); if (!(bool)invoker.Call("IsBuffered")) { return; } if (rule.Debug) { response.Write("\r\n<!--Served from edge at " + TimeStamp + " by rule " + rule.Name + "-->"); response.AddHeader("X-Edge-Modified", TimeStamp); response.AddHeader("X-Edge-Rule", rule.Name); } object rawResponse = invoker.Call("GetSnapshot"); string cacheKey = keyBuilder.GetResponseCacheKey(rule.CacheKeyStamp(context)); CacheDependency dependency = new CacheDependency(null, new string[] { DependencyKeyFromRule(rule) }); OutputCacheSnapshot snapshot = new OutputCacheSnapshot(rawResponse); DateTime expiry = rule.AbsoluteExpiry; HttpRuntime.Cache.Add(cacheKey, snapshot, dependency, expiry, Cache.NoSlidingExpiration, CacheItemPriority.Normal, null); }
private void OnResolveRequestCache(object sender, EdgeCacheEventArgs e) { EdgeCacheRule rule = (EdgeCacheRule)sender; HttpContext context = e.Context; HttpResponse response = context.Response; HttpRequest request = context.Request; OutputCacheKeyBuilder keyBuilder = new OutputCacheKeyBuilder(context); OutputCacheSnapshot snapshot = null; foreach (string cacheKey in keyBuilder.EnumerateRequestCacheKeys(rule.CacheKeyStamp(context))) { snapshot = (OutputCacheSnapshot)HttpRuntime.Cache[cacheKey]; if (snapshot != null) { break; } } if (snapshot != null && snapshot.Response != null) { bool sendBody = !String.Equals(request.HttpMethod, "HEAD", StringComparison.InvariantCultureIgnoreCase); new DynamicInvoke(response) .Call("UseSnapshot", snapshot.Response, sendBody); response.AddHeader("X-Edge", snapshot.Description); OnPreSendSnapshot(new EdgeCacheRuleEventArgs(e.Context, rule)); context.ApplicationInstance.CompleteRequest(); } }