我可以看到stackoverflow添加了他们Expires
的Cache-Control
图片、css、js等,所以我也在尝试做同样的事情,我试过这篇文章
网络配置
<location path="Content">
<system.webServer>
<staticContent>
<clientCache cacheControlCustom="public" cacheControlMode="UseMaxAge"
cacheControlMaxAge="365.00:00:00" />
<clientCache cacheControlMode="UseExpires" httpExpires="Mon, 01 May 2023 00:00:00 GMT" />
</staticContent>
</system.webServer>
</location>
当我尝试访问内容文件夹中的 css 文件时:http://localhost:11111/Content/bootstrap.min.css
我收到以下错误
错误:
HTTP 错误 500.19 -
Internal Server Error 无法访问请求的页面,因为该页面的相关配置数据无效。
Module CustomErrorModule Notification SendResponse Handler StaticFile Error Code 0x8007000d
已定义配置错误配置元素“clientCache”
我知道clientCache
已经定义了,但我很担心,想知道如何在响应标头中设置 Cache-Control 和 Expires ?
任何帮助都会很棒。
更新:
正如@Vitaly Kulikov 在评论中回答和讨论的那样,使用这篇文章和这篇文章我得出的结论是,在 IIS 中,我们可以Expires and Cache-Control
在 web.config 中进行设置,因此我计划使用OutputCache至少为图像设置 Expires,它适用于0.9毫秒延迟。希望能帮助某人。