Do you know how to configure Client side Caching IIS7? Cache your static resources to client side by tweaking web.config in windows hosting.
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 a 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 to 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 on Client side Caching IIS7.
If you liked this article, then please subscribe to our Blog for more updates like this. You can also connect me on Twitter, LinkedIn and GitHub.
Recent Comments