Recently I have described how you can use WP Super Cache specifically for windows hosting, and my previous post to optimize and speed up MVC website by several tricks using web.config. What if your website has plenty of static resources and you want to completely avoid server request. Well here is the way you can enable client-side caching by tweaking web.config.

Step 1# Make your cache to live longer how ?here is block you need

<configuration>
<system.webServer>
<staticContent>
<clientCache cacheControlMaxAge=”365.00:00:00″ cacheControlMode=”UseMaxAge” />
</staticContent>
</system.webServer>
</configuration>

Step 2# Make your static content to cache on client side, and here is handy block you need to add in your web.config under<system.webserver>

<caching>
<profiles>
<add extension=”.js” policy=”CacheUntilChange” kernelCachePolicy=”DontCache” location=”Client” />
<add extension=”.css” policy=”CacheUntilChange” kernelCachePolicy=”DontCache” location=”Client” />
<add extension=”.html” policy=”CacheUntilChange” kernelCachePolicy=”DontCache” location=”Client” />
<add extension=”.htm” policy=”CacheUntilChange” kernelCachePolicy=”DontCache” location=”Client” />
<add extension=”.gif” policy=”CacheUntilChange” kernelCachePolicy=”DontCache” location=”Client” />
<add extension=”.jpg” policy=”CacheUntilChange” kernelCachePolicy=”DontCache” location=”Client” />
<add extension=”.jpeg” policy=”CacheUntilChange” kernelCachePolicy=”DontCache” location=”Client” />
<add extension=”.zip” policy=”CacheUntilChange” kernelCachePolicy=”DontCache” location=”Client” />
</profiles>
</caching>

If you have other known extensions you can add here, just change your extension.

For location, you have choice to cache

If you are caching on server side too make sure you change your location from “Client” to “Any”

Here is the source if you want to dig into more details.

Let me know your experience of caching data in comment!!