我想在cachecontrol和httpExpires标题中设置web.config,方法是按照对What's the difference Expires and Cache-control:max-age?问题的回答。
<system.webServer>
<staticContent>
<clientCache cacheControlCustom="public" cacheControlMaxAge="12:00:00" cacheControlMode="UseMaxAge" />
<clientCache cacheControlCustom="public" httpExpires="Tue, 19 Jan 2038 03:14:07 GMT" cacheControlMode="UseExpires" />
</staticContent>
</system.webServer>但由于某种原因,当我这样做的时候,图像变得不可用了。
每次加载图像时都会出现Failed to load resource: the server responded with a status of 500 (Internal Server Error)错误(我可以看到browser dev tools console中的错误)。
我想我把它配置错了?
如果我只留下一个单独的clientCache部分就可以了
怎么解决这个问题?
更新:刚刚又问了一个相关的问题how to set up both httpexpires and cachecontrol headers web.cofig
发布于 2015-01-22 14:31:47
此IIS Client Cache page声明,‘虽然“过期”和“最大年龄”设置有点错误,“最大年龄”指令优先于“过期”。但是,当一个“最大年龄”clientCache条目与一个“过期”clientCache条目并行使用时,IIS会生成HTTP500错误。
当调整IIS中的“设置公共标头”时,“过期”和“最大年龄”是相互排斥的。你可以使用一种或另一种,但不能两者兼用。
其他缓存指令可应用于Web.config中的子文件夹或特定文件。关于在stackoverflow page中配置缓存内容,请参见此IIS7。
发布于 2016-12-15 12:01:09
<staticContent>
<clientCache cacheControlCustom="public;max-age" cacheControlMode="UseMaxAge" cacheControlMaxAge="10.00:00:00" />
</staticContent>
<urlCompression dynamicCompressionBeforeCache="true" />这对我来说很好,可以缓存10天的请求。
https://stackoverflow.com/questions/20826035
复制相似问题