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

In IIS7, I have 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 also have the following for "caching"

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

What is the difference between these two configurations? They are both nested in the <system.webServer> , so they are both valid for IIS7.

Also, what is the correct approach when using them? Currently, I use only this folder with my static assets. I do not use this caching for anything else.

Thanks in advance.

+8
caching web-config iis-7
source share
2 answers

The main difference is that the first caching is server-side (it basically stores the page output in memory for subsequent requests), the second is on the client side (response headers will be included, they tell the browser how to manage cached files locally on the client machine).

+4
source share

I noticed that people often confuse things above and write articles where they recommend things, as in the first block, i.e. output caching for static resources

Output Caching :

Output caching is not required for static files, such as HTML, JPG or GIF, and can lead to increased memory overhead for a dynamic ASP.NET or PHP page that is read from a frequently changing database.

Thus,

 <add extension=".png" ../> <add extension=".jpeg" ../> etc. 

useless at least when you don't have an HTTP pedestrian handler for .png or .jpeg etc.

0
source share

All Articles