ramsTecH1
ramsTecH1

Reputation: 207

How to set Leverage browser caching asp.net

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

Answers (1)

Chawathe Vipul S
Chawathe Vipul S

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

Related Questions