我有来自 YSlow 的报告:
(no expires) http://static3.scirra.net/avatars/128/40cfdcbd1b1ec1842e199c97c4b85a4a.png
(还有很多相似之处)。不过,在我的 web.config 中,我有:
<system.webServer>
<staticContent>
<clientCache httpExpires="Sun, 29 Mar 2020 00:00:00 GMT" cacheControlMode="UseExpires" />
</staticContent>
<caching>
<profiles>
<add extension=".ashx" policy="CacheForTimePeriod" kernelCachePolicy="DontCache" duration="01:00:00" />
<add extension=".png" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" location="Any" />
</profiles>
</caching>
<rewrite>
<rules>
<rule name="Avatar">
<match url="avatars/([0-9]+)/(.*).png" />
<action type="Rewrite" url="gravatar.ashx?hash={R:2}&size={R:1}" appendQueryString="false" />
</rule>
</rules>
</rewrite>
这不应该正确添加过期标头吗?我的目标是:
- Gravatar.ashx 从 Gravatar 服务器获取图像
- 服务器缓存结果 1 小时(类似于 SO)
- 添加了 Expires 标头,因此客户端不会继续从我的服务器获取它