Kernel-mode caching for ASP.NET Web API

Topics: ASP.NET Web API, General
Jul 19, 2013 at 4:15 PM
Edited Jul 19, 2013 at 7:26 PM
Hi, I am looking into HTTP.SYS kernel model caching and have a simple test application running in IIS which returns a simple content.
        public HttpResponseMessage Get(int id)
            Trace.WriteLine("Get " + id);
            var response = Request.CreateResponse(HttpStatusCode.OK, "chessbase");
            response.Content.Headers.Expires = new DateTimeOffset(2014, 1, 1, 1, 1, 1, TimeSpan.Zero);
            response.Content.Headers.LastModified = new DateTimeOffset(2012, 1, 1, 1, 1, 1, TimeSpan.Zero);

            response.Headers.CacheControl = new CacheControlHeaderValue()
                                                    Public = true,
                                                    MaxAge = TimeSpan.FromDays(1)
            return response;
Following guidelines from here, I am sending correct headers but when I look at the Kernel performance counters (such as "Kernel: current URIs cached") I see absolutely no caching. On the other hand, I can see kernel caching for the item, no even ASP.NET caching since my action gets hit all the time.

First of all, is it possible to use kernel mode output caching with ASP.NET Web API? And if so what am I missing?

I am going mad!



I had a look at MVC's OutputCache and I can see that it uses ASP.NET's Page class from Web Forms to implement the output caching. And this actually does not result in Kernel caching, but user-mode caching.