Saturday 18 February 2017

Blob Cache in SharePoint


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.
By default, it looks like this:
BlobCache location="C:\blobCache" path="\.(gif|jpg|png|css|js)$" maxSize="10" enabled="false" />
 
In order to improve the performance of your site, the BlobCache should be enabled.
BlobCache location="C:\blobCache" path="\.(gif|jpg|png|css|js)$" maxSize="10" enabled="true" />
 
Example:
BlobCache location="C:\blobCache" path="\.(gif|jpg|png|css|js)$" maxSize="10" max-age="86400" enabled="false"/>










• 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.


Flush the BLOB cache web application:-
$webApp = Get-SPWebApplication ""
[Microsoft.SharePoint.Publishing.PublishingCache]::FlushBlobCache($webApp)
Write-Host "Flushed the BLOB cache for:" $webApp