Enabling BLOB Cache in SharePoint using PowerShell

One of the ways of improving performance of your SharePoint is by enabling the BLOB Cache. The BLOB cache is a disk-based cache that stores binary large objects (BLOB’s) on the web server to reduce the load on the database server by avoiding unneccessary round trips to that server. Read all about it on TechNet.

The BLOB Cache is disabled by default and enabling it needs to be done on the web application level in the web.config. There’s a specific setting in the web.config where you can enable this.

To enable it, you just change the value of the “enabled” attribute to true and there… it’s done.

But wait, if you have multiple web servers, you need to do this on each server. Not quite amusing. Let’s do something about that. If you use a SPWebConfigModification, the change is pushed automatically to all web servers which have the WFE role. Time to flex those fingers and create some PowerShell code.

This script accepts 2 parameters:

  • Url : URL of the web application for which you want to enable the BLOBCache
  • Location : the place on disk where the cache is stored

In the script, 3 updates are performed:

  • Enabled=”true” : Enables the BLOB Cache
  • max-age=”86400″ : Sets the age (in seconds) that a browser caches BLOBs
  • location : Sets the path on disk where the cache is stored