Leverage browser caching with web.config in .net?

Ivan picture Ivan · Apr 23, 2011 · Viewed 15.7k times · Source

Some of sites are on shared hosting (Windows 2003 Server), so I have no way to access server configuration.

I read everywhere about leverage browser caching, expecially for static files (jpg, css, js, etc.) but... how to do this in my case?

The hosting has .NET installed, could a web.config file help in some way? If yes, how?

Answer

CUTTHEMUSIC picture CUTTHEMUSIC · Oct 1, 2011

Here is how I did on my site that is on a shared host. I believe the cacheControlMaxAge is as follows days:hours:minutes:seconds but dont quote me.

<system.webServer>  
    <staticContent>
        <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="3.00:00:00" />
    </staticContent>
</system.webServer>