Configuring BLOB Cache in SharePoint

What is BLOB:
BLOB means Binary Large Object and refers any binary format file that is stored as a single entity  and not converted to text. Usually, BLOB files are of type images, audio/video files.

What is BLOB Cache:
When BLOB types of files are uploaded to a SharePoint site (E.g. Images, CSS, Scripts on a pages), they are stored inside the SQL Server content databases in BLOB data fields. When users request for these files for the first time, SharePoint retrieves them from database, stores the copies in WFEs and from next time, it serves those files from WFEs instead going back to database. So, enabling the SharePoint BLOB cache will improve the performance of your sites and reduce the load on your database servers.

What benefit We'll Get by Enabling BLOB Cache in SharePoint?
A file retrieved from Web Front End's File System is much faster, compared with when it retrieved from the database! It helps to improve performance by decreasing the number of requests from SQL Server! It reduces end-user response time too.

Although, it is possible to enable the BLOB cache for all file types, its usually enabled for images, scripts, audio/video media file types and its ideal for Public web sites and sites where most of the users will have read-only permissions. (of course, BLOB could also be a document or spreadsheet even!)

Warning: Do not configure blob cache on collaborative file types such as Microsoft Word Documents! Because: The latest version of the document should be always be retrieved from the database and free from and conflicts. That would cause negative effect!!

How to configure the BLOB cache in SharePoint 2010/2013/2016:
The BLOB cache is configured in the web.config file for each Web application. Since BLOB cache is not enabled by default, it must be manually configured. To configure BLOB cache, we need to modify the web.config file of the WFE server(s). Follow this Step by step instruction to setup blob cache in SharePoint 2010.

1. Log on to SharePoint WFE server(s) as a Administrator

2. Go to Internet Information Services (IIS) Manager.

3. Expand the server, Sites node and then select your target the web application

4. Right-click the web application and click Explore to open the file system directory for the web application.
sharepoint 2010 blob cache configuration
5. Open the web.config file in any text editor such as Notepad.
sharepoint 2010 blob cache web config
6. Locate the following line in the web.config file:

By default, BLOB Cache configuration in Web.Config file would be:

<BlobCache location="C:\BlobCache\14" 
            maxSize="10" enabled="false" />

Simply change the enabled property to "true" to enable BLOB cache! SharePoint will create the folder specified in location parameter and assign folder permissions automatically!
sharepoint 2010 blob cache
How to Disable BLOB caching in SharePoint?
E.g. If you are frequently updating images or CSS files, you might want to disable blog caching at least temporarily.To disable BLOB cache in SharePoint 2010, simple revert it back to "false".

BLOB Cache Configuration has the following Parameters:
  • location - Is the file system folder where SharePoint server stores cached files.Make sure you select the BLOB cache location on a drive with sufficient disk space!
  • path - Is a lists all file extensions that will be cached. File types are separated by vertical pipe character.
  • maxSize - In GB, disk space that the BLOB cache will occupy. If BLOBs exceeds this limit, SharePoint will delete older items in the cache to make room for newer items.
  • max-Age - In seconds. It tells How long Browser can cache these files without making request to the server. Use it with value: 1814400 (Three Weeks), if you get: HTTP 304 error!
  • enabled - Sets BLOB Cache ON or OFF. Make it "false" to disable BLOB Cache.
XML is case sensitive! so be cautious when making changes to web.config file.

If your SharePoint server farm consists of more than one web front end web server, you must repeat editing web.config file in each web server! So lets enable blob cache using PowerShell.

How to Enable BLOB Cache using PowerShell?
Why not! Web.config file changes can be made with "SPWebConfigModification" class. Lets utilize that to make a web.config change to enable BLOB cache:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Get the Web Application
$WebApp = Get-SPWebApplication "" 

#Create a web.config modification
$WebconfigMod = New-Object Microsoft.SharePoint.Administration.SPWebConfigModification
$WebconfigMod.Path = "configuration/SharePoint/BlobCache"
$WebconfigMod.Name = "enabled"
$WebconfigMod.Sequence = 0
$WebconfigMod.Owner = "BlobCacheModification"
$WebconfigMod.Type = 1
$WebconfigMod.Value = "true"
#Apply the web.config change
This will enable BLOB Cache. If you want to disable BLOB cache, just change the Parameter "enabled" to "false". Same method applies for additional parameters such as: Location, MaxSize, etc.

See the BLOB Cache in action:
how to enable blob cache sharepoint 2010

How to Flush(Reset/Clear) BLOB cache in SharePoint 2010
Some times, You may notice your changes don’t appear in the site. All you have to do is: Flush the Cache! Here is the PowerShell to flush the BLOB cache (No GUI to do this!).
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

$webApp = Get-SPWebApplication ""
Write-Host "BLOB Cache Flushed for:" $webApp 

Blob cache in SharePoint 2010/2013 foundation?
BLOB cache is not supported in SharePoint Foundation versions! This feature is available only in SharePoint Server!

Update: Although its written for SharePoint 2010, same procedure and steps applies for SharePoint 2013 and SharePoint 2016!

1 comment:

  1. "XML is case sensitive"....Cough **Microsoft's** XML is case sensitive which is really stupid and they give you no way to turn that off.


Please Login and comment to get your questions answered!

Powered by Blogger.