As part of IIS performance tuning to improve a web page load speed, in general you want to enable browser caching by double-clicking on HTTP Response Headers in IIS Manager, click on Set Common Headers and check the Expire Web content:, then set the After: with an x number of days.
Often times though, you may want to be more granular in IIS static content caching for different type of files or all static files under certain folders. In the same way that you can disable browser caching for specific files on IIS, you can also configure the web.config to setup browser caching for specific files or directories with different lengths of time.
<configuration> ... <location path="favicon.ico"> <system.webServer> <staticContent> <clientCache cacheControlCustom="public" cacheControlMode="UseMaxAge" cacheControlMaxAge="365.00:00:00" /> </staticContent> </system.webServer> </location> <location path="js"> <system.webServer> <staticContent> <clientCache cacheControlCustom="public" cacheControlMode="UseMaxAge" cacheControlMaxAge="60.00:00:00" /> </staticContent> </system.webServer> </location> <location path="images"> <system.webServer> <staticContent> <clientCache cacheControlCustom="public" cacheControlMode="UseMaxAge" cacheControlMaxAge="30.00:00:00" /> </staticContent> </system.webServer> </location> </configuration>
In this example we can see the caching for a specific file favicon.ico is set to 1 year (365 days) and two folders js and images are set to 60 and 30 days respectively (In a format of days.hours:minutes:seconds). This means, all static files under js folder will be cached for 60 days, similarly for images folder, although for less duration since the contents change more frequently.
By caching as many static files as possible on the browser, you can tremendously improve IIS performance, which translates to better users experience in loading your site faster on their subsequent visits.