我正在尝试了解以下缓存配置:
<!--Configures expiration for files in CMS/VPP-->
<staticFile expirationTime="12:0:0" />
<!--Configures expiration in IIS-->
<system.webServer>
<!--Configures client headers for static files from IIS-->
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="1.00:00:00"></clientCache>
</staticContent>
<!--Configures output and kernel caching for ALL images (both CMS and IIS)-->
<caching>
<profiles>
<add extension=".gif" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" duration="0.00:01:00" location="Any" />
<add extension=".png" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" duration="0.00:01:00" location="Any" />
<add extension=".js" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" duration="0.00:01:00" location="Any" />
<add extension=".css" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" duration="0.00:01:00" location="Any" />
<add extension=".jpg" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" duration="0.00:01:00" location="Any" />
<add extension=".jpeg" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" duration="0.00:01:00" location="Any" />
</profiles>
</caching>
</system.webServer>
</configuration>
因此,静态文件将作为cacheControlMaxAge =“ 1.00:00:00”缓存1天。但是我对为什么要这样做感到困惑:
<staticFile expirationTime="12:0:0" />
哑剧类型的有效期也为1分钟:
<caching>
<profiles>
<add extension=".gif" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" duration="0.00:01:00" location="Any" />
<add extension=".png" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" duration="0.00:01:00" location="Any" />
<add extension=".js" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" duration="0.00:01:00" location="Any" />
<add extension=".css" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" duration="0.00:01:00" location="Any" />
<add extension=".jpg" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" duration="0.00:01:00" location="Any" />
<add extension=".jpeg" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" duration="0.00:01:00" location="Any" />
</profiles>
</caching>
那么这是否意味着所有静态内容都缓存了1天,还是特定于设置?就像其他文件一样,mime类型是1天,mime类型是1分钟。
答案 0 :(得分:0)
<staticFile>
是非标准的。这似乎是EPiServer.Web.StaticFileHandler的配置元素。 <system.webServer>
正在配置IIS。使用哪种配置取决于处理请求的模块。
https://docs.microsoft.com上的文档非常好:https://docs.microsoft.com/en-us/iis/configuration/system.webserver/staticcontent/clientcache
除此以外,我想说的是,没有什么比尝试一下更好的方法了。在大多数浏览器上,您可以按F12并打开developer tools。向静态文件发出请求,然后查看“网络”选项卡。读取响应标头,例如Cache-Control,Last-Modified等。