Friday 14 February 2014

SharePoint BLOB caching and max-age attribute


SharePoint provides BLOB caching feature which when enabled will improve the performance of SharePoint sites by caching frequently used files in physical storage and using it for subsequent requests for the files.

Though the SharePoint BLOB caching feature is handy, care must be taken when using this feature as sometimes the changes made to the cached files will not be reflected in users browsers. This happens primarily because when the SharePoint BLOB caching feature is enabled in web.config without any additional settings it takes the default max-age property of 86400 which is one day. The caveat here is contrary to what most people think max-age property is not the duration is not the expiration period for the files stored in BLOB cache. Max-age is specifies the duration that the client browsers should cache the files. Examining the SharePoint file requests using fiddler tool you would notice the difference in max-age value as shown in the images below

Cache max-age when SharePoint BLOB cache is disabled


 
Cache max-age when SharePoint BLOB cache is enabled
 
If files in your SharePoint site will be changed more frequently than a day then you need to set appropriate value for max-age attribute for BLOB cache as shown below


<BlobCache location="<Cache folder location>" 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" max-age=”3600” />
 
Sean has a great article that details the request and response flow when SharePoint BLOB cache is enabled.

No comments:

Post a Comment