Preventing Azure cache folders from bloating

   —   

This article describes how to clean Azure cache folders on a regular basis so they do not take up all the available space on the local disk

If you utilize external storage like Azure blobs, you might have noticed the files from the storage are cached on the local file system of the web server as well.

Until now, the only way to prevent the system from taking up all the free space on the disk was to manually check how much these Azure cache folders take up and delete the unnecessary files from there upon review.

However, now there is a scheduled task “Clean Azure storage cache” available which takes care of automatic deletion of those cached files. Additionally there are 3 web.config keys that allow you to specify detailed settings for the deletion:

CMSAzureStorageCacheCleanerThreshold – specifies a threshold in gigabytes; when the threshold is exceeded, the system starts to delete files from the oldest to the newest until the result target size is achieved; the default value is 45 GB
<add key="CMSAzureStorageCacheCleanerThreshold" value="45"/>

CMSAzureStorageCacheCleanerKeepLimit - the amount is the target size (in gigabytes) of the Azure Cache and Azure Temp folders when the scheduled task deletes the files; for example, if the amount is set to 10GB, the Azure Cache and Azure Temp folders have in total the size of 10GB, after the scheduled task runs and the threshold is exceeded
<add key="CMSAzureStorageCacheCleanerKeepLimit" value="10"/>

CMSAzureStorageCacheCleanerExcludedPaths - specifies relative paths from which the system does not delete the cached files
<add key="CMSAzureStorageCacheCleanerExcludedPaths" value="folder_name1;folder_name2"/>

To import the scheduled task to your Kentico instance, all you need to do is simply add the code file to your App_Code folder (or CMSApp_AppCode -> Old_App_Code if the project is installed as a web application). The task is registered to your system automatically.

Please note the scheduled task will be built-in in Kentico 9 once it is released.

Additionally, for Kentico 8.0, you need to adjust the scheduled task a bit and change the references for “PathHelper.CachePath/TempPath” to “AzureHelper.CachePath/TemPath”.

Download link for the scheduled task - AzureStorageCacheCleaner.cs

Share this article on   LinkedIn

Filip Ligač

Hi, I work as a Cloud Support Specialist here at Kentico. I write about Microsoft Azure and and am trying to extend knowledge about the best practices for deployment.

Comments