在我的 web.config 中,我正在尝试为静态内容添加缓存:
<system.webServer>
<staticContent>
<clientCache cacheControlMode="UseExpires" httpExpires="Sun, 1 Jan 2020 00:00:00 UTC" />
</staticContent>
<modules runAllManagedModulesForAllRequests="true" />
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<add path="*" name="ServiceStack.Factory" type="ServiceStack.HttpHandlerFactory, ServiceStack" verb="*" preCondition="integratedMode" resourceType="Unspecified" allowPathInfo="true" />
</handlers>
</system.webServer>
但是,当我运行 YSlow!我仍然得到“添加过期标题”的 F 级;因此,似乎图像、CSS 和 Javascript 文件等静态内容没有被缓存。
我如何在 ServiceStack 中完成此操作,因为我所做的 web.config 更改没有被 ServiceStack 接收;这在 ASP.NET MVC 中确实有效,但是如何使用过期标头服务器静态内容?
我也试过这个,但我的静态文件仍然没有被缓存。
<system.webServer>
<staticContent>
<clientCache cacheControlMaxAge="30.00:00:00" cacheControlMode="UseMaxAge"/>
</staticContent>
</system.webServer>