IIS映像缓存指令导致500.19错误

时间:2016-01-20 14:54:42

标签: caching iis iis-7.5 browser-cache

我想在IIS上向浏览器添加缓存标头。我找到了这个: IIS 7.5 and images not being cached

<staticContent>
    <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="1.00:00:00" />
</staticContent>
<httpProtocol>
    <customHeaders>
        <add name="Cache-Control" value="public" />
    </customHeaders>
</httpProtocol>

这解决了Google在PageSpeed测试时发出警告的缓存问题: https://developers.google.com/speed/pagespeed/insights/

但这也会导致500.19错误,它会说:&#34;配置部分&#39; staticContent&#39;无法阅读,因为它缺少部分声明&#34;

我的web.config文件看起来像这样:

<?xml version="1.0"?>
<configuration>
    <appSettings/>
    <connectionStrings/>
    <system.web>
        <compilation debug="false"></compilation>
        <authentication mode="Windows"/>
    </system.web>
    <system.webServer>
        <httpErrors errorMode="Custom">
            <remove statusCode="404" subStatusCode="-1"/>
            <error statusCode="404" prefixLanguageFilePath="" path="/rewrite.asp" responseMode="ExecuteURL"/>
        </httpErrors>
    </system.webServer>
</configuration>

如何防止此错误?

0 个答案:

没有答案