Loading

Referring to the article "Best practices for speeding up your website" 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.



This will only work with IIS7.
I haven't test it my self, but I found some feedback from the other users.

Category: asp.netiis7
Bookmark and Share

Comment and make your thoughts visible

blog comments powered by Disqus