Search This Blog

Tuesday, February 10, 2015

Configuring BLOB Cache in SharePoint 2010

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 on a page), 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.

What benefit We'll Get by Enabling BLOB Cache in SharePoint 2010
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:
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 configuredTo 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:

?
1
2
3
<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 location parameter and assign folder permissions automatically! To disable BLOB cache in SharePoint 2010, simple revert it back to "false".
sharepoint 2010 blob cache
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.

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:
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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()



No comments:

Post a Comment