您的标头显示您添加了新值,但需要替换现有值
Cache-Control:no-cache, no-store,Public
Expires:-1,Sun, 29 Mar 2020 00:00:00 GMT
no-cache, no-store
代表没有缓存并且-1
说内容已经过期了。
您可以轻松地在根 web.config 文件中将其设置为
<location path="images">
<system.webServer>
<staticContent>
<clientCache cacheControlMode="UseExpires"
httpExpires="Sun, 29 Mar 2020 00:00:00 GMT" />
</staticContent>
</system.webServer>
</location>
</configuration>
其中 images 是目录的名称
或者直接在目标目录中添加专用的web.config文件
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<staticContent>
<clientCache cacheControlMode="UseExpires"
httpExpires="Sun, 29 Mar 2020 00:00:00 GMT" />
</staticContent>
</system.webServer>
</configuration>
您还可以使用cacheControlMode =“UseMaxAge”并设置特定的过期时间
设置 7 天后过期的示例
<clientCache cacheControlMode="UseMaxAge"
cacheControlMaxAge="7.00:00:00" />
阅读更多http://msdn.microsoft.com/en-us/library/ms689443.aspx http://msdn.microsoft.com/en-us/library/ms689443.aspx