Tuesday, November 6, 2007

Controlling the BLOB

The third part of the caching trilogy covers the BLOB cache, or binary large object cache. In a typical site there are many references to CSS files and images. MOSS caches these objects to prevent multiple trips to the database for these resources. MOSS caches these resources on the Web-front end servers in the file system. This type of caching is not enabled by default.

To enable BLOB caching change the line in the Web.config file for the blobcache to true. You can set the maximum size for the cache in this line as well. The default is 10 GB. In the path attribute you can determine the file extensions that will be cached in this type of caching. You may want to add such file extensions as .swf for Flash movies, if your site utilizes them. NOTE: this caching only works on items that are in document libraries and lists. If you place files in the site but not in a library or list, the caching will not cache the file.

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


You can also set the maxAge to the number of seconds that you want the client to retain the object in its cache. This allows the client to use its copy of the resource and not re-request the URL for the resource until the timeout has expired.

With these three types of caching your Internet facing MOSS site can efficiently serve up files to many users.

Additional resources for caching:

Microsoft Enterprise Content Management (ECM) Team Blog
Custom Caching Overview


Labels: , , , ,

Thursday, October 25, 2007

The Object of My Cache

In the first post on caching I explained the output cache and how it can speed up your MOSS site. In this post I will explain the object cache. This cache comes ready to use in MOSS by default and does not require much tweaking except for the size of the cache.

Since MOSS uses SQL Server to store all the content of a site, it can get pretty expensive to make round trips to the database for each piece of content, so MOSS stores the most used objects such as document library and list fields and site navigation on the disk. This caching is very granular and is less expensive over time.

As the site administrator you can adjust the maximum disk size alloted for the object cache. The default is 100MB per site collection. In order to find the right size for this cache you will need to monitor the Sharepoint Publishing Cache in performance monitor. Keep an eye on the publishing cache hit ratio, and the total object discards counters to give you an idea of how you should adjust the cache size.

To change the size of the cache:

1. Click site actions->site settings->modify all site settings

2. Click Site Collection Object Cache

3. Change the value of Max. Cache Size and click OK.


One thing to keep in mind when using all of the different caches is that they all share the same virtual memory within the process. If you set the object cache really high that leaves less memory available for the other types of caching. If you are running on a 32-bit operating system then the W3WP process has a maximum limit of 2GB to use for the application. This 2GB also includes the space alloted to dll's and modules loaded by MOSS. A good rule of thumb for the object cache is to start at 200MB and increase it until the hit ratio is low high (< 85%). You can also test the cache by hitting the pages and seeing the response time for a user.

In the next post I will cover disk-based (BLOB) caching.

Labels: , , ,