Tuesday, 5 May 2015

Configure BLOB cache for SharePoint 2010 web applications

SharePoint 2010 supports disk-based BLOB Cache that controls the caching for binary large objects. If you configure BLOB for frequently used images, audio files, video files, java script files, css files etc., the performance will be improved. BLOB cache needs to be enabled in the front end web server and once configured; the configured files will be retrieved from the database and stored in a directory under Front end web server. This reduces the network traffic/load on the database server. 
You need to carefully decide whether or not to use the BLOB cache. You need to carefully decide what files need to be placed under BLOB cache. For e.g. placing documents under BLOB cache in a collaboration portal will give you negative effect as the documents will be authored by users frequently. 
Consider the following points for configuring the BLOB cache.
For a publishing site for which most of the visitors are anonymous or where most of the files are static content, enable the BLOB cache for as many file types as possible.
For other sites that contain lots of media assets that are read-only, or where only a small percentage of the media assets are updated, enable the BLOB cache for media files only.
Be noted that you can have only one BLOB cache per web application. Each web front end server will have its own copy of BLOB cache. In load balancing scenarios, each web server will have its own copies and the files will be added to the blob cache individually by the front end server when it serve the file for the first time.
The BLOB cache needs to specify in the web.config for each web application. By default, the BLOB caching is disabled. Open the web.config for the web application that you need to configure the BLOB cache. Normally you find the following line in the web.config of the web application.
<BlobCache location="<location>" path="<files to be cached>" maxSize="10" enabled="true" />
Modify the following attributes
location – the path to the directory where the blob files stores in the disk. 
path – specifies the condition for file names that will be included in the cache. By default SharePoint will include a regular expression that matches certain extensions. In most of the cases you just need to add/remove some extentions to the list. 
maxSize – the maximum size for the cache expressed in GB, 10 GB is the default
enabled - specifies whether blob cache is enabled or not. True indicates enabled
e.g. 
<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" />
Flush output cache
In some situations, you need to flush the output cache. You can do this by using the following PowerShell commands
$webApp = Get-SPWebApplication "<http://your web application url>"
[Microsoft.SharePoint.Publishing.PublishingCache]::FlushBlobCache($webApp)

No comments:

Post a Comment