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|jpeg|jpe|jfif|bmp|dib|tif|tiff|ico|png|wdp|hdp|css|js|asf|avi|flv|m4v|mov|mp3|mp4|mpeg|mpg|rm|rmvb|wma|wmv)$” maxSize=”10″ enabled=”true” />
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.
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 Object Cache Flush and Force all servers in the farm to flush their object caches.
In SharePoint 2010, you’ll use the following PowerShell commands to flush the BLOB Cache: