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
asyncResult==null ? null : asyncResult.m_pOverlapped,
null );
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?

One Comment

  1. Posted July 15, 2013 at 8:04 am | Permalink | Reply

    I think the biggest benefit of HttpListener / http.sys is the inherent it works with TCP port and URL endpoint sharing between multiple processes. And secondly, that it is a hardened HTTP stack that you don’t really need to worry about; just use it like an API.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: