MVC Client Cache for Static content is not working

2.4k Views Asked by At

I've added below one in web.config

<staticContent>
   <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="10.00:00:00" />
</staticContent>

But I'm not seeing expires on response headers. Should I do any other changes?

enter image description here

1

There are 1 best solutions below

0
On

I would try two things to debug. First I would change cacheControlCustom from private to public

<location path="Content">
  <system.webServer>
    <staticContent>
      <clientCache 
             cacheControlCustom="public" 
             cacheControlMode="UseMaxAge" 
             cacheControlMaxAge="10.00:00:00" />
    </staticContent>
  </system.webServer>
</location>

If that does not work check the location of your path covered for caching. Your example is not showing that part.

Lastly, try to unlock StaticContent section of machine config via:

appcmd unlock config /section:staticContent

Here is a link with some additional useful information Client Cache.