Configuring BLOB Cache in SharePoint

What is BLOB?
BLOB means Binary Large Object and refers to 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 pages), they are stored inside the SQL Server content databases in BLOB data fields. When users request these files for the first time, SharePoint retrieves them from the database, stores the copies in WFEs, and from next time, it serves those files from WFEs instead of going back to the 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, it’s usually enabled for images, scripts, audio/video media file types, and it’s ideal for Public websites 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 set up 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" 
       path="\.(gif|jpg|jpeg|bmp|tiff|ico|png|css|js|avi|flv|m4v|mov|mp3|mp4|mpeg|mpg|wma|wmv)$" 
            maxSize="10" enabled="false" />

Simply change the enabled property to “true” to enable BLOB cache! SharePoint will create the folder specified in the 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 – This is the file system folder where the SharePoint server stores cached files. Make sure you select the BLOB cache location on a drive with sufficient disk space!
  • path – It is a list of all file extensions that will be cached. File types are separated by a 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 a 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. Let us 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 "http://sharepoint.crescent.com" 

#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
$WebApp.WebConfigModifications.Add($WebconfigMod)
$WebApp.Update()
$WebApp.Parent.ApplyWebConfigModifications() 

This will enable BLOB Cache. If you want to disable BLOB cache, just change the Parameter “enabled” to “false”. The same method applies to 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?

Sometimes, You may notice your changes don’t appear on 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 "http://sharepoint.crescent.com"
[Microsoft.SharePoint.Publishing.PublishingCache]::FlushBlobCache($webApp)
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 it’s written for SharePoint 2010, same procedure and steps applies for SharePoint 2013 and SharePoint 2016!

Salaudeen Rajack

Information Technology Professional with Two decades of SharePoint Experience.

One thought on “Configuring BLOB Cache in SharePoint

  • July 13, 2015 at 8:42 PM

    “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.

    Reply

Leave a Reply