Monday 7 December 2015

ASP.NET Tips #56 - Cache your static content by directory

If you have a directory of content like JavaScript, images, and CSS, place a web.config in that content directory to cache your static content.

For example, if you had a directory called 'Contents' with an images, styles, and scripts directory underneath it, you would place a web.config (similar to below) in just the content directory.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
   <system.webServer>
      <staticContent>
         <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="1.00:00:00" />
      </staticContent>
   </system.webServer>
</configuration>

You can include this web.config in any static directory to gain maximum caching web performance.

For more details, kindly visit https://www.iis.net/configreference/system.webserver/staticcontent/clientcache

No comments :

Post a Comment