本文介绍了IIS7 Web.Config 缓存 - 这里有什么区别,它们是如何结合在一起的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 IIS7 中,我可以设置缓存选项.这些选项被添加到我的 web.config 中......

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>

这两个配置有什么区别?它们都嵌套在 <system.webServer> 标记中,因此它们都对 IIS7 有效.

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.

提前致谢.

推荐答案

主要区别在于

  • 第一个是用于服务器端缓存动态输出,例如aspx页面(基本上将页面输出保存在内存中以供后续请求使用).正如@artem-vertiy 的回答所指出的,将其用于静态内容毫无意义.

  • 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.

这篇关于IIS7 Web.Config 缓存 - 这里有什么区别,它们是如何结合在一起的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-18 19:37