Confusion on IIS Kernel and user mode Cache

Alex81122 21 Reputation points
2022-11-08T05:52:08.583+00:00

Hi all,
i have a confusion on the IIS output caching, especially on the kernel mode cache.

In the documentation "Configure iis output caching", it is mentioned that "IIS automatically caches static content (such as HTML pages, images, and style sheets), since these types of content do not change from request to request."

However, based on my understanding, one of the feature of kernel cache is to speed up static file performance significantly by bypassing the need to do a kernel-to-usermode transition to generate and serve the response. (https://redmondmag.com/articles/2001/07/24/kernelmode-caching-should-add-speed-in-iis-60.aspx)

Does that mean that if i disable kenel cache mode, all the static content will not be cached at all? It seems to contradict to the first statement where IIS automatically caches static content.

Further to this, i would also like to confirm whether the user mode cache will cache static content or mainly on dyanmic content based on the rules added. If no rules are added in the output caching, what is the default behaviour for the user mode cache?

Thanks

Reference :
Configure IIS output caching - https://learn.microsoft.com/en-us/iis/manage/managing-performance-settings/configure-iis-7-output-caching

Internet Information Services
0 comments No comments
{count} votes

Accepted answer
  1. Yurong Dai-MSFT 2,781 Reputation points Microsoft Vendor
    2022-11-08T10:13:50.837+00:00

    Hi @Alex81122 ,

    In order to improve performance, IIS will internally cache static files such as js, html, gif, png, etc. by default. This cache is in the memory of the server iis process. IIS doing this can greatly improve the access performance of static files. Under normal circumstances, as long as the static files are updated, IIS will also update the cache.

    The IIS output caching feature targets semi-dynamic content. It lets you cache static responses for dynamic requests and increase scalability. Windows Server supports two caching methods:

    • User Mode Cache - Use a local cache stored in the IIS worker process
    • Kernel Mode Cache - Use the cache stored in the Http.sys driver.

    Kernel-mode caching essentially handles caching requests at the OS level, so content stored in it can be accessed without going through other common pipes (i.e. it doesn't have to go into the ASP.NET or IIS level cache to inspect the content). The kernel-mode cache is designed to take frequently accessed files and stick them in the kernel for faster retrieval.

    User mode will fill the void where kernel mode cannot be used, it mostly revolves around authorization/authentication stuff (since it needs to check if the user can actually access the content), but there are many other scenarios where the http.sys cache might not be used.

    Even if you disable kernel cache mode, it will not affect IIS caching static content, which is not contradictory. If there is no output cache rule under IIS, only static content is cached, and the output cache is used to cache (semi) dynamic content.

    Update:

    Here are supplementary answers to some of your questions:

    1.How do we determine the content is semi-dynamic since even dynamic content may contain static content. It seems to me most dynamic page shall be classify under semi-dynamic page.
    2.Does that mean that if the page is html, it won't be cached by output cache as per ", IIS will internally cache static files such as js, html, gif, png, etc. by default"

    Web content can be divided into two categories: static content and dynamic content.

    • Static content does not vary from request to request. The content returned to the web browser is always the same. Examples of static content include HTML, JPG, or GIF files.
    • Dynamic content is output that changes with each request. Examples include ASP.NET or PHP content.

    Between these two categories is semi-dynamic content. Such as when you have a dynamic ASP.NET page that performs database queries. If the underlying database tables don't change frequently, there's no reason to do this query on every request.

    IIS automatically caches static content (such as HTML pages, images, and style sheets) because these types of content do not vary from request to request. IIS also detects changes to files when you update, and IIS flushes the cache as needed. As for the IIS output caching feature, semi-dynamic content is targeted. It allows you to cache static responses for dynamic requests and improve scalability.

    Of course not every dynamic page can take advantage of output caching. Highly personalized pages (such as shopping carts or e-commerce transactions) are not good candidates because dynamic output is less likely to be requested repeatedly and the memory used to cache content is wasted. Content output due to POST type requests to HTML forms is also not cacheable.

    The best candidates for output caching are pages that generate data dynamically but are unlikely to change between requests based on URL or header information. For example, a photo gallery type application that dynamically resizes images for display in a web page is a good candidate for output caching, because caching the data frees the server from having to re-process resizing images for each request. Another good example of a type of application that can take advantage of the output cache feature is a stock ticker application.

    Under Output Cache -> Edit Feature Setting, what is the effect of Enable Cache checkbox if no cache rules are added? It seems to me this setting has to work hand-to-had with the Cache Rules, or more precisely user-mode cache. But if there is no cache rules added, does this mean the content will not be cached in user mode?

    Enable cache - This property specifies whether output caching is enabled for this URL. If disabled, the output cache module will do nothing during the ResolveRequestCache and UpdateRequestCache phases. Setting enabled to true does not ensure response caching. Some modules must have a user cache policy set.

    Enable kernel cache – This property controls whether kernel caching is enabled for this URL. Setting enableKernelCache to true does not ensure that the kernel cache is responsive. Some modules must set a kernel cache policy.

    You can get more information from this blog. Hope my answer can help you.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the email notification for this thread.

    Best regards,
    Yurong Dai


0 additional answers

Sort by: Most helpful