两部分问题(部分密切相关):使用 IIS7 采用的默认 OOTB ETag 策略,为什么我们在浏览页面时看不到 If-None-Match/304 交互?
例如,为空缓存请求返回的标头是:
Content-Type image/png
Last-Modified Thu, 03 Dec 2009 15:51:56 GMT
Accept-Ranges bytes
Etag "a8a0628a3074ca1:0"
Server Microsoft-IIS/7.0
X-Powered-By ASP.NET
Date Tue, 22 Dec 2009 19:47:36 GMT
Content-Length 1780
...但随后对该页面的访问不会为图像生成 304 往返?
此外,IIS7 的默认applicationHost文件具有以下 (1):
<caching enabled="true" enableKernelCache="true">
</caching>
enableKernelCache='true'是否扩展到所有静态文件,使您无需显式注册扩展以授予CacheUntilChange作为内核策略 (2):
<caching>
<profiles>
<add extension=".gif" policy="DontCache" kernelCachePolicy="CacheUntilChange" duration="0.00:01:00" location="Any" />
<add extension=".png" policy="DontCache" kernelCachePolicy="CacheUntilChange" duration="0.00:01:00" location="Any" />
<add extension=".js" policy="DontCache" kernelCachePolicy="CacheUntilChange" duration="0.00:01:00" location="Any" />
<add extension=".css" policy="DontCache" kernelCachePolicy="CacheUntilChange" duration="0.00:01:00" location="Any" />
<add extension=".jpg" policy="DontCache" kernelCachePolicy="CacheUntilChange" duration="0.00:01:00" location="Any" />
<add extension=".jpeg" policy="DontCache" kernelCachePolicy="CacheUntilChange" duration="0.00:01:00" location="Any" />
</profiles>
</caching>
(1) %systemroot%\System32\inetsrv\config\applicationHost.config
(2) http://labs.episerver.com/en/Blogs/Per/Archive/2009/3/Configuring-cache-expiration-on-IIS-7/