Preventing Azure cache folders from bloating

Kentico projects connected to the Azure Blob Storage (Cloud Services by default, Web Apps optionally and standard applications connected to the 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:

Using direct links to files

When linking to files located on the blob storage, we recommend using direct links (for example, /site/media/imagelibrary/picture.png) instead of links through the application (beginning with /CMSPages/GetAzureFile.aspx...). Direct access to files reduces the number of files cached in the AzureTemp and AzureCache folders.

To be able to use direct links to files:

  1. Configure the main container on your blob storage to be public – add the following setting to your application:

    <add key="CMSAzurePublicContainer" value="true" />

     

  2. Make sure that the Use permanent URLs option in Settings application -> Content -> Media is not selected.

The system can now use direct links to files on the blob storage.

Note: Automatic resizing of images does not work when using direct links to files on a blob storage.

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, Kentico 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.

  1. Open the Scheduled tasks application.
  2. Leave (global) in the Site drop-down list.
  3. Edit () the Clean Azure storage cache scheduled task.
  4. Modify the Period or other properties of the task according to your needs.
    • The scheduled task uses the CMS.AzureStorage.AzureStorageCacheCleaner class.
  5. 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, i.e., 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"/>

Was this page helpful?