How to add Expires headers in ASP.NET

To set Expires headers in ASP.NET, add the following in web.config.

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

In the above example Expires are set for 30 days, 0 hours, 0 minutes and 0 seconds.

We use cookies for your best experience.