Enable the SharePoint Blob Cache For Performance Gains
Written By: Wahid Saleemi -- 12/28/2010 --
(2122) comments --
Categories: Configurations, MOSS 2007, SharePoint 2010, SharePoint Foundation 2010, System Administration, WSS3
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
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
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
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|png|css|js|avi|wmv)$” maxSize=”10” max-age="43200" enabled=”true” />
Remember to reset IIS after any changes to a web.config by typing IISRESET
/noforce in a command prompt window.
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. You can see this in the Event Viewer.
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 Disk Based Cache Reset.
If your SharePoint 2007 farm consists of more than one web front-end, you may
not see the objects flushed. This is because the request is only sent to the web
server that is currently in use by the logged-in user. However, you can easily
overcome this by using STSADM. The following command will reset the BLOB Cache
on all web servers in the SharePoint 2007 farm:
STSADM -o setproperty -propertyname blobcacheflushcount -propertyvalue 11 -url https://url-of-web-application
In SharePoint 2010, you'll use the following PowerShell commands to flush the
$webApp = Get-SPWebApplication "<WebApplicationURL>"