HttpListener in .NET

I have heard at least 20 different presentations inform me that one of the super awesome benefits of using a HttpListener in .NET is that it goes through http.sys which will allow you to have kernel mode caching inside of http.sys. They then explain why this is so much better because it doesn’t require a transition to user mode and blah blah blah.

Guess what they lied. In actually measuring this possible performance gain I found it was non-existent. After some poking through reference sources I came across:

line 525
UnsafeNclNativeMethods.HttpApi.HttpSendHttpResponse(
HttpListenerContext.RequestQueueHandle,
HttpListenerRequest.RequestId,
(uint)flags,
pResponse,
null,
null,
SafeLocalFree.Zero,
0,
asyncResult==null ? null : asyncResult.m_pOverlapped,
null );
http://msdn.microsoft.com/en-us/library/windows/desktop/aa364499(v=vs.85).aspx
Argument 5 is the CACHE_POLICY. It is set to null which means no caching.
The bigger question is why on earth would microsoft not allow you to use the http caching you pay a big complexity penalty to have access to?
This entry was posted in Uncategorized. Bookmark the permalink. Follow any comments here with the RSS feed for this post.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>