IIS 7.5 and images not being cached

后端 未结 2 1467
孤城傲影
孤城傲影 2020-12-24 03:02

I cannot get the image files to cache. I have tried everything that I have found on this site and others and still cannot get them to cache.

Web config setting that

相关标签:
2条回答
  • 2020-12-24 03:36

    The following should cause the browsers to cache your images:

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

    The <caching>...</caching> block is for server-side caching, not client side caching.

    0 讨论(0)
  • 2020-12-24 03:36

    In case anyone needs to configure your site as Chrome Audits or GTMetrix require I've configured my environments with the following (thanks to Marco's answer):

    <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="365.00:00:00" />
    

    using 365 days and both tools took that value as acceptable for a cache time.

    0 讨论(0)
提交回复
热议问题