public void Process(System.Web.HttpContext current, IResponseArgs e) { current.RemapHandler(new Return304Handler(e)); }
/// <summary> /// Sends the response directly to the client with no caching logic. /// </summary> /// <param name="context"></param> /// <param name="e"></param> public void Process(System.Web.HttpContext context, IResponseArgs e) { context.RemapHandler(new NoCacheHandler(e)); // The following line of code does nothing. I don't think there is any way to make this work before .NET 2.0 SP2 //context.Handler = new NoCacheHandler(e); }
void Pipeline_PostAuthorizeRequestStart(System.Web.IHttpModule sender, System.Web.HttpContext context) { if ((context.Request.FilePath.EndsWith("/resizer.debug", StringComparison.OrdinalIgnoreCase) || context.Request.FilePath.EndsWith("/resizer.debug.ashx", StringComparison.OrdinalIgnoreCase))) { //Communicate to the MVC plugin this request should not be affected by the UrlRoutingModule. context.Items[c.Pipeline.StopRoutingKey] = true; //Provide the request handler IHttpHandler handler =AllowResponse(context) ? (IHttpHandler)new DiagnosticPageHandler(c) : (IHttpHandler)new DiagnosticDisabledHandler(c); context.RemapHandler(handler); // The following line of code does nothing. I don't think there is any way to make this work before .NET 2.0 SP2 //context.Handler = handler; } }
public void Process(System.Web.HttpContext current, IResponseArgs e) { var modDate = e.HasModifiedDate ? e.GetModifiedDateUTC() : DateTime.MinValue; var key = e.RequestKey + "|" + modDate.Ticks.ToString(NumberFormatInfo.InvariantInfo); CacheEntry entry; byte[] data; //Ensure cache is loaded if (!loaded) Load(); if (!TryGetData(key ,out data, out entry)){ Stopwatch sw = new Stopwatch(); sw.Start(); //Cache miss - process request, outside of lock MemoryStream ms = new MemoryStream(4096); e.ResizeImageToStream(ms); data = StreamExtensions.CopyToBytes(ms,true); sw.Stop(); //Save to cache entry = PutData(key,data, sw.ElapsedMilliseconds); } ((ResponseArgs)e).ResizeImageToStream = delegate(Stream s) { s.Write(data,0,data.Length); }; current.RemapHandler(new NoCacheHandler(e)); if (cache.changes_since_cleanse > ChangeThreshold) CleanseAndFlush(); else if (cache.changes_since_cleanse > 0 && DateTime.UtcNow.Subtract(lastFlush) > new TimeSpan(0, 0, 30)) { Flush(); } }