Enable the SharePoint Blob Cache For Performance Gains

​SharePoint 2007 and 2010 allows users to store media files such as pictures and videos and display them on a SharePoint page. These media files and other page artifacts (like css and javascript) can be very slow to load. This is because each time the files are accessed they are pulled from the SharePoint Content Database by default. For external facing sites in particular, images and javascript can consume most of the load time for a page.

Let’s see how we can use a feature called the BLOB Cache to speed up loading of media and other files.

BLOB caching, or disk-based caching, is an out of the box (OOTB) caching mechanism that is built into the MOSS 2007 and SharePoint Server 2010 platforms. It is commonly used to speed-up access to large and relatively static resources that are stored in content databases, such as images, videos, javascript files, and more. Performance improvements are gained by storing these assets on web servers once they’ve been requested by a client. This allows SharePoint to serve subsequent requests for such assets directly from web servers instead of round-tripping to the content database each time a request for such an asset is received. For most SharePoint sites, this type of caching can significantly lighten the load on your SQL Servers and back-end network.

BLOB Caching is controlled through the web.config file for each of the IIS web sites that is associated with a Web application, and it is not enabled by default. Enabling BLOB caching is as simple as setting the enabled attribute to true in the < BlobCache/> web.config element as shown below.


 

<BlobCache location=”C:\BlobCache\14″ path=”\.(gif|jpg|jpeg|jpe|jfif|bmp|dib|tif|tiff|ico|png|wdp|hdp|css|js|asf|avi|flv|m4v|mov|mp3|mp4|mpeg|mpg|rm|rmvb|wma|wmv)$” maxSize=”10″ enabled=”true” />


 

The “maxSize” attribute is the size in gigabytes. So any files over 10GB in our example won’t be cached. You can specify any file types you want to be cached in the “path” attribute, just add a pipe symbol and add the file extension. Finally, take note of the “location” attribute. If this folder doesn’t exist, it will be created.

 Resources that are served from a web servers BLOB cache when the max-age attribute is used are only re-requested after the max-age interval has elapsed or the browser’s local cache has been cleared. In our example above, our “max-age” is set to 43200 seconds. This is equivalent to 12 hours. Change this value based on your environments needs.

If the cache needs to be flushed before the expiration is reached, you can reset the object cache. In SharePoint 2007, a Site Collection Administrator can perform a reset. To do so, go to Site Collection Administration, Site Collection Object Cache, and check Object Cache Flush and Force all servers in the farm to flush their object caches.

In SharePoint 2010, you’ll use the following PowerShell commands to flush the BLOB Cache:

$webApp = Get-SPWebApplication “<WebApplicationURL>”
[Microsoft.SharePoint.Publishing.PublishingCache]::FlushBlobCache($webApp)

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s