Enable the SharePoint Blob Cache For Performance Gains
Let's see how we can use a feature called the BLOB Cache to speed up loading of media and other files.
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 BLOB Cache:
$webApp = Get-SPWebApplication "<WebApplicationURL>"
- Review Custom Caching Overview on MSDN.
- Review Cache Settings Operations on TechNet.
- Configure these settings in a test environment to assess its impact. Use tools like Fiddler2 or Visual Studio tests to record load times.
About the author
View all my tips