Channels ▼
RSS

IIS Kernel Caching


IIS Kernel Caching

ASP.NET page output caching is the feature that allows you to cache page responses so that successive requests can be satisfied without reexecuting the page, but simply by returning the cached output. Page caching is smart enough to let you save distinct output based on the requesting URL, query string, or form parameters.

When ASP.NET runs under IIS 6.0, the web server may optionally intervene and serve previously cached pages before ASP.NET kicks in. When integrated in the web server, the output caching mechanism provides much better performance and responsiveness.

IIS can cache a copy of the page output and serve it again through the http.sys kernel-level driver. The output caching facility in IIS 6.0 has been used by ASP.NET since Version 1.1 to host the output cache. So, when using the output cache directive in ASP.NET 1.1 and ASP.NET 2.0 applications, most of your responses are being served from the kernel cache. This form of integration will continue and get even stronger with the advent of the next version of IIS.

It is important to note that page output caching works only for anonymous content. Requests for cached pages served by IIS 6.0 never reach stages in the ASP.NET pipeline where they can be authenticated. The output caching feature, especially if implemented at the kernel level, has tremendous potential and can dramatically improve the performance of a web server, as long as enough of the content being served is cacheable. What's the performance gain you can get?

According to the numbers provided with the IIS 6.0 technical documentation, an application using the kernel cache returns a throughput of over 10 times the throughput you would get in the noncached case. Additionally, the latency of responses is significantly better. To get more information and comparable tables, go to http://www.microsoft.com/technet/prodtechnol/ windowsserver2003/technologies/webapp/iis/iis6perf.mspx.

In particular, the parameters that indicate the number of requests served per second and time-to-last-byte are dramatically better; most of the CPU utilization is in kernel mode and a larger number of context switches per second occur when output caching is integrated in IIS 6.0.

To enable an ASP.NET page for output caching, you have to decorate it with the @OutputCache directive. The great news for developers, though, is that, aside from this, no other code changes are required to benefit from kernel caching. There's something more to know about kernel caching, though. While kernel caching can really boost the performance of a high-volume web site, some limitations apply. First and foremost, kernel caching is available only for pages requested through a GET verb. No kernel caching is possible on postbacks and POST requests in general. Furthermore, pages with VaryByParam and VaryByHeader attributes set are also not stored in the kernel cache. Finally, note that ASP.NET Request/Cache performance counters will not be updated for pages served by the kernel cache.

When kernel caching is impossible, ASP.NET tries its best and caches page responses internally in the Cache object. In this case, the limitations you observe with kernel caching (such as POST requests) disappear, but the performance is worse. All in all, though, for relatively static pages that do not require clicking, even a one second cache may be a great improvement.


Dino Esposito is Wintellect's ADO.NET and XML expert, and a trainer and consultant based in Rome, Italy. Dino is a contributing editor to Windows Developer Network and MSDN Magazine, and the author of several books for Microsoft Press including Building Web Solutions with ASP.NET and ADO.NET and Applied XML Programming for .NET. Contact Dino at dinoe@wintellect.com.



Related Reading


More Insights






Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

 
Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.
 

Video