Preventing Azure cache folders from bloating
Xperience projects connected to the Azure Blob Storage cache temporary data from the blob storage in the file system. The temporary data is stored in the Azure Temp and Azure Cache folders located in your web application’s local file system.
When these folders contain too much data, your web application’s local storage can get bloated and lack free storage for new data. The system can also display errors for not having enough space on the disk.
We recommend the following measures to prevent these folders from containing too much data:
- Configuring a CDN for your storage
- Structuring media library files into folders
- Configuring the Clean Azure storage cache scheduled task
Structuring media library files into folders
Structure the files in your media libraries into folders of up to 100 files. See Media library limitations when storing files in an external storage for details.
Configuring the Clean Azure storage cache scheduled task
To prevent the Azure Temp and Azure Cache folders from bloating, Xperience uses the Clean Azure storage cache scheduled task. The scheduled task browses through the folders and if a threshold is exceeded, the system deletes the configured amount of files starting from the oldest files.
You can set:
- The frequency of evaluation of the parameters (threshold)
- The threshold when the system starts deleting old files
- How many gigabytes of data stay in the system after the deleting occurs
- Excluded paths that are never deleted
Modifying the scheduled task
You can modify the frequency of evaluating the parameters in the Scheduled tasks application.
- Open the Scheduled tasks application.
- In the Site selector, choose either (global) or a specific site.
- The global task runs for the Xperience administration application.
- For the live site application, the task must be site-specific and have the Run task on property set to Live site. You may need to create the task manually for your site (for example by cloning the default global task).
- Edit () the Clean Azure storage cache scheduled task.
- Modify the Period or other properties of the task according to your needs.
- The scheduled task uses the CMS.AzureStorage.AzureStorageCacheCleaner class.
- Click Save.
The scheduled task now runs according to your changes.
Modifying related web.config keys
Set the web.config file to affect the process of cleaning the Azure Temp and Azure Cache folders.
CMSAzureStorageCacheCleanerThreshold
This web.config key 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 (specified by the CMSAzureStorageCacheCleanerKeepLimit web.config key) while excluding the specified paths (set by the CMSAzureStorageCacheCleanerExcludedPaths web.config key).
The default value if the key is not specified is 45GB.
Use the following syntax to add the web.config key:
<add key="CMSAzureStorageCacheCleanerThreshold" value="45"/>
CMSAzureStorageCacheCleanerKeepLimit
This web.config key specifies an amount in gigabytes. The amount is the target size 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.
The default value, i.e., if the key is not specified, is 10GB. The size of the excluded paths (set by the CMSAzureStorageCacheCleanerExcludedPaths web.config key) is included in the amount.
Use the following syntax to add the web.config key:
<add key="CMSAzureStorageCacheCleanerKeepLimit" value="10"/>
CMSAzureStorageCacheCleanerExcludedPaths
This web.config key specifies relative paths separated by semicolons (;). The system does not delete files inside the paths typed in the web.config key in both the AzureTemp and AzureCache folders.
There is not any predefined excluded path by default.
Use the following syntax to add the web.config key (the system does not delete the AzureTemp/folder_name1, AzureTemp/folder_name2, AzureCache/folder_name1 and AzureCache/folder_name2 folders):
<add key="CMSAzureStorageCacheCleanerExcludedPaths" value="folder_name1;folder_name2"/>