Kernel-Mode caching does not support VaryByHeaders in IIS 10

Aishwarya Rajan 0 Reputation points
2023-02-13T11:20:18.64+00:00

Hi,

I have a use case, where some js files are enabled for kernelCaching. The files are getting cached correctly, but when the file is retrieved there is a mismatch due to encoding of the file.
For eg:

When I enable only gzip compression, gzip compressed file is returned.

When I enable only brotli compression, brotli compressed file is returned.

When I enable both gzip and brotli compression, because brotli is of higher priority in my list, brotli compressed file should be returned, however gzip compressed file is returned. And this behaviour is inconsistent, sometimes gzip compressed file is returned, sometimes brotli compressed file is returned.

On reading some articles, I found that we can add this option of varyByHeaders to return files based on headers. However, that is available on User-Mode caching only and not on Kernel-Mode caching.

as per the screenshot below.

Is VaryByHeaders supported for kernel-caching?

If yes, how to enable it?

If no, how to vary the files based on encoding when kernel cache is enabled? (Disabling it will cause performance impact in my case.)

User's image

Windows 10
Windows 10
A Microsoft operating system that runs on personal computers and tablets.
12,077 questions
Internet Information Services
.NET
.NET
Microsoft Technologies based on the .NET software framework.
4,104 questions
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,598 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Sam Wu-MSFT 7,556 Reputation points Microsoft External Staff
    2023-02-14T03:14:41.9933333+00:00

    @Aishwarya Rajan

    The kernel-mode output cache supports the varyByHeaders attribute, but not varyByQuerystring.

    Select a Cache Policies

    varyByHeaders specifies a semicolon-separated list of HTTP headers used to vary the output cache. When this attribute is set to multiple headers, the output cache contains a different version of the requested document for each combination of specified headers. you can try to set it in the profiles property.

    More information you can refer to this link: Configuration Sample.


    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 related email notification for this thread.


  2. Lex Li (Microsoft) 6,022 Reputation points Microsoft Employee
    2023-02-16T05:14:45.3666667+00:00

    Deleted deleted.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.