3 out of 3 rated this helpful - Rate this topic

Disk-based Caching for Binary Large Objects

Disk-based caching controls caching for binary large objects (BLOBs) such as image, sound, and video files, as well as code fragments. Disk-based caching is extremely fast and eliminates the need for database round trips. BLOBs are retrieved from the database once and stored on the Web client. Further requests are served from the cache and trimmed based on security.

Enabling and Modifying Disk-based Caching

Disk-based caching is disabled by default. To enable and customize the disk-based cache, you must modify the following statement in the web.config file for the SharePoint Web application mapped to the Internet Information Services (IIS) Web site:

<BlobCache location="C:\blobCache" path="\.(gif|jpg|png|css|js)$" maxSize="10" max-age="86400" enabled="false"/>

In the preceding example:

  • location is the directory where the cached files will be stored

  • path specifies in the form of a regular expression which files are cached based on the file extension

  • maxSize is the maximum allowable size of the disk-based cache in gigabytes

  • max-age specifies the maximum amount of time in seconds that the client browser caches BLOBs downloaded to the client computer. If the downloaded items have not expired since the last download, the same items are not re-requested when the page is requested. The max-age attribute is set by default to 86400 seconds (that is, 24 hours), but it can be set to a time period of 0 or greater.

  • enabled is a Boolean that disables or enables the cache

Flushing the Disk-based Cache

  1. On the Site Actions menu, point to Site Settings, and then click Modify All Site Settings.

  2. Under Site Collection Administration, click Site collection object cache.

  3. In the Disk Based Cache Reset section, do one or more of the following:

    • To force the server to reset its disk-based cache, select Force this server to reset its disk based cache.

    • To force all servers to reset their disk-based caches, select Force all servers in the farm to reset their disk based cache.

    If you select one or more of the check boxes, all entries in the disk caches are flushed immediately when you click OK. If you do not select any of the check boxes, the disk caches are left unchanged and item expiration is managed, with items being removed when they are changed in the site or when the disk size is exceeded.

  4. Click OK.

See Also

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
CORRECTION - article should NOT read (ambiguously) "... on the web client"
Just a note for those of you who are new to caching, a statement in the article could/should be very confusing:

"Disk-based caching is extremely fast and eliminates the need for database round trips. BLOBs are retrieved from the database once and stored on the Web client."

This key sentence SHOULD read as follows:
"Disk-based caching is extremely fast and eliminates the need for database round trips. BLOBs are retrieved from the database once and stored on the Web Front End Server(s)."

Web clients are commonly understood (and rightly so) to be the actual laptops & desktop computers running browsers (web clients). To say Disk-Based Caching stores content on the "web client" would cause novices to caching to think that somehow key content is now being duplicated (cached) on each & every laptop/desktop browsing to a SharePoint site. While this IS attractive (we'd all LOVE to take that load off our servers!), it is - sadly - INCORRECT.

Disk-Based Caching is done at each of the Web Front Ends (WFEs) in a SharePoint farm. It caches key content so it needn't be re-requested from the database server for EVERY SINGLE PAGE being requested. This necessarily demands massive RAM on each WFE, or the result will be that Disk-Based Caching could conceivably cause WORSE performance because an under-RAMed WFE will be swapping out memory calls to disk (HD) just to implement caching. This could be more harmful than simply disabling disk-based caching - go figure.

Anyhow, shame on Team SharePoint for not more carefully proof-reading such critical content. In my 9+ years consulting on SharePoint, I've witnessed that proper caching can make or break an enterprise-level SharePoint deployment, and I always find it annoying when I see such poor monitoring of such key content. :-|

Cheers,
-MV (www.markvogt.us)
The switch "Force all servers in the farm to reset their disk based cache" is not visible

In the Disk Based Cache Reset section, the Force all servers in the farm to reset their disk based cache, is not available (at least, not with the May 20th rollup).

However, by looking at the code using Reflector, we can see that the checkbox does exist but, in the OnLoad event, its visibility is set to false. The good thing is that the necessary code is available in it, which is also similar to the stsadm command available at http://msdn.microsoft.com/en-us/library/aa622758.aspx, however, the stsadm command only works once. The reason is that the property value needs to be incremented each time.

You can use the following code to flush the BlobCache on all servers:


SPSite site = new SPSite(http://adventureworks);
string s = "0";
if (site.WebApplication.Properties.ContainsKey("blobcacheflushcount") && site.WebApplication.Properties["blobcacheflushcount"] != null)
s = site.WebApplication.Properties["blobcacheflushcount"] as string;
site.WebApplication.Properties["blobcacheflushcount"] = (int.Parse(s, CultureInfo.InvariantCulture) + 1).ToString(CultureInfo.InvariantCulture);
site.WebApplication.Update();
site.Dispose();