Showing posts with label Page Speed Optimization. Show all posts
Showing posts with label Page Speed Optimization. Show all posts

Friday, November 8, 2013

How to add Expiry Headers to Static Content from web.config

The easiest way to add the expiry headers or cache control in static content from web.config file is:

Add following line of code in web.config file.
 <system.webServer>
    <staticContent>
       <clientCache cacheControlCustom="public"
    cacheControlMaxAge="720:00:00" cacheControlMode="UseMaxAge" />
    </staticContent>  

  </system.webServer>


Look at the value cacheControlMaxAge="720:00:00"  it suggests the static content will be cached in users browsers for 30 days. This works perfectly and this is the easiest way to handle the cache control in asp.net web site.