Asp.Net(MVC或非MVC)Web应用程序的Web.config文件在system.webServer部分有两个缓存指令是很常见的:
<staticContent>
<clientCache cacheControlMaxAge="07.00:00:00" cacheControlMode="UseMaxAge" />
</staticContent>
这个将所有静态内容的缓存控制设置为Max-Age :(现在+ 7天)
在同一部分下也有这个指令:
<caching>
<profiles>
<add extension=".jpg" location="Any" policy="CacheForTimePeriod" duration="7.00:00:00" kernelCachePolicy="CacheUntilChange" />
</profiles>
</caching>
此指令将.jpg文件的缓存标头设置为过期:7天,并为所有位置启用缓存(代理,浏览器等...)
我没有得到的是,哪个指令优先于另一个?如果省略.jpg的配置文件,是否需要clientCache指令的值? (假设它由静态文件处理程序处理)
“kernelCachePolicy”实际上做了什么?
答案 0 :(得分:1)
首先,这个参数是关于如何保存缓存的IIS的说明。
静态内容缓存,使IIS自动添加客户端标题,并向浏览器说明将内容保存在缓存中以及持续多长时间。
静态内容是不会改变的内容,如图像。
<staticContent>
<clientCache .... />
</staticContent>
您提到的第二个缓存是服务器端缓存。如果用于动态制作的页面,它更好用。它将渲染的页面保存在内存中,并在询问时从那里给出。
<caching>
<profiles>
<add .... />
</profiles>
</caching>
您可以在此处阅读更多内容:What are difference between IIS (Dynamic and Static) cache,OutPutCache and browser cache
也在IIS网站上
http://www.iis.net/configreference/system.webserver/staticcontent/clientcache
http://www.iis.net/configreference/system.webserver/caching