IIS7 Web.Config 缓存 - 这里有什么区别,它们是如何结合在一起的?
在 IIS7 中,我能够设置缓存选项。这些选项被添加到我的 web.config 中...
<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>
但是,我还获得了以下“缓存”选项,
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="90.00:00:00" />
<remove fileExtension=".js" />
<mimeMap fileExtension=".js" mimeType="text/javascript" />
</staticContent>
这两个配置之间有什么区别?它们都嵌套在
标记中,因此它们都对 IIS7 有效。
另外,使用这些时正确的方法是什么?我目前只使用我的静态资产文件夹。我不会在其他任何事情上使用此缓存。
提前致谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
主要区别在于,
第二个是“互联网端”:它是通过编写标准响应头来实现的,它告诉客户端浏览器和公共代理如何管理缓存文件。
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.
我注意到人们经常混淆上面的内容,并撰写文章来推荐第一块中的内容,即静态资源的输出缓存
输出缓存:
因此
至少当您没有 .png 或 .jpeg 等的 ashx http 处理程序时是无用的。
I've noticed that people often confuse the things above and write articles where recommend things as in the first block, i.e. output caching for static resources
Output caching:
Thus
is useless at least when you don't have ashx http handler for .png or .jpeg etc.