Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IIS7 Web.Config Caching - what are the differences here, and how does it all come together?

In IIS7 I've got the ability to set caching options. These options are added to my web.config as such...

    <caching maxCacheSize="262144">
        <profiles>
            <add extension=".png" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" duration="00:00:30" />
            <add extension=".jpeg" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" duration="00:00:30" />
            <add extension=".jpg" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" duration="00:00:30" />
            <add extension=".css" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" duration="00:00:30" />
            <add extension=".js" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" duration="00:00:30" />
        </profiles>
    </caching>

However, I've also got the following for "caching"

    <staticContent>
        <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="90.00:00:00" />
        <remove fileExtension=".js" />
        <mimeMap fileExtension=".js" mimeType="text/javascript" />
    </staticContent>

What are the differences between these two configs? They are both nested in the <system.webServer> tag, so they're both valid for IIS7.

Also, what is the right approach when using these? I currently only use this is my static assets folder. I don't use this caching on anything else.

Thanks in advance.

like image 462
Chase Florell Avatar asked Jan 30 '11 04:01

Chase Florell


People also ask

What is IIS output caching?

The IIS output caching feature targets semi-dynamic content. It lets you cache static responses for dynamic requests and increase scalability. Note that not every dynamic page can take advantage of the output cache.

Is Web config cache?

At run time, ASP.NET uses the Web. Config files to hierarchically compute a unique collection of configuration settings for each incoming URL request. These settings are calculated only once and then cached on the server.

What is kernel cache in IIS?

IIS Kernel Mode Caching Rules The IIS output cache supports two cache policies. The regular output cache policy takes advantage of a cache that resides in an IIS worker process. The other cache policy is a kernel mode cache policy, in which case the cache resides in HTTP. SYS, a kernel-mode driver.


1 Answers

The main difference is that

  • the first is for server-side caching of dynamic output such as aspx pages (basically keeps the page output in memory for subsequent requests). As @artem-vertiy's answer points out, using it for static content makes no sense.

  • the second one is 'internet-side' : it is implemented by writing standard response headers, it tells both client browsers and public proxies how to manage cached files.

like image 155
Superzadeh Avatar answered Oct 05 '22 07:10

Superzadeh