Reputation: 207
How to set Leverage browser caching at ASP.net IIS 7.0 Setting an expiry date or a maximum age in the HTTP headers and for pictures in web.config file
Upvotes: 1
Views: 2515
Reputation: 1696
For ASP.net, in the global.asax file, in the Application_PreRequestHandlerExecute function call Response.Cache.SetExpires and Response.Cache.SetMaxAge methods. For pictures or static content, in IIS 7 web.config use
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="7.00:00:00" />
</staticContent>
replacing 7 days with desired duration.
Upvotes: 2