How to add expires headers in ASP.NET


Referring to the article “Best Practices for Speeding Up Your Web Site”from YUI, adding "Expires Header" to static files can improve the load time of the web site. After searching around for answer on how to add expires header to my static files (e.g JPG, CSS, JS and etc), I found the solution below is the easiest to implement.
Add the configuration shown below in the in web.config file. Below is the sample configuration setup that cache the static files for 14 days before expired.
Add Expires header in ASP.NET using <clientCache> in web.config. 
<system.webServer>
  <staticContent>
    <clientCache cacheControlMaxAge="14.00:00:00" cacheControlMode="UseMaxAge"/>
  </staticContent>
</system.webServer>
This implementation is confirmed with Firebug as shown in the snapshot taken below.


I don’t get paid for writing blog posts. Your “Like” is my only motivation, so please “Like” it if you found this information useful. Cheers!!!