My system.webServer > staticContent > clientCache element obstructs serving CSS, JavaScript, and Images

StackOverflow https://stackoverflow.com/questions/23177408

Вопрос

I have this system.webServer section. When I add the clientCache line, the web server stops serving JavaScript, CSS, and images. When I remove the clientCache line, it again starts serving them. What is wrong with my clientCache element?

This problem occurs both in the Visual Studio development server and when I push the Website to Azure.

<system.webServer>
    <staticContent>
      <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="86400"/>
    </staticContent>
    <!--Handlers removed for clarity-->
</system.webServer>
Это было полезно?

Решение

In ASP.NET, the clientCache > cacheControlMaxAge property is a timespan (though the HTTP specification makes its max-age header seconds.)

So, this is wrong:

<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="86400"/>

And this is right:

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

Where was the ISO on this one?

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top