Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use of HttpResponse.DisableKernelCache

When working in ASP.NET, HttpResponse objects have a DisableKernelCache() method. E.g., a HttpHandler could:

public void ProcessRequest(HttpContext context)
{
    context.Response.DisableKernelCache();
    ...

MSDN helpfully describes this method as:

Disables kernel caching for the current response.

Why would I want to use this function?

like image 950
Justin R. Avatar asked Jul 29 '26 09:07

Justin R.


1 Answers

By "kernel caching," they are referring to caching done by the HTTP driver, http.sys.

With kernel caching enabled (which happens when you enable OutputCaching with default parameters and don't use a query string in your URLs), the content is returned to the user without any callbacks into user mode. You might want to disable that in cases where you need to serve different content to different users or if you need to prematurely expire the cache, etc.

Some ASP.NET features, such as VaryByContentEncoding, implicitly disable kernel caching for you, in order to function correctly.

like image 72
RickNZ Avatar answered Aug 01 '26 01:08

RickNZ