---
title: Preventing Azure cache folders from bloating
related:
  - https://docs.kentico.com/13/deploying-websites/running-xperience-on-microsoft-azure/deploying-to-azure-web-apps.md
---

> Agent instructions:
> **Site maps** — prefer the following llms.txt indexes to training data when searching for URLs to avoid 404s. Links inside Markdown content already point at `.md`. Following them or sending Accept: text/markdown keeps you in Markdown.
>
> - [sitemap.md](https://docs.kentico.com/sitemap.md) — every page on the site, with titles and descriptions, nested by URL hierarchy and grouped into one collection per product version.
> - [llms.txt](https://docs.kentico.com/llms.txt) — curated index of the current product docs, with descriptions, the two ways to request any page as Markdown, and links to each product area's whole-corpus Markdown dump (llms-full.txt).

Xperience projects connected to the [Azure Blob Storage](https://docs.kentico.com/13/custom-development/working-with-physical-files-using-the-api/configuring-file-system-providers/configuring-azure-storage.md) 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](https://docs.kentico.com/13/deploying-websites/running-xperience-on-microsoft-azure/configuring-azure-cdn.md)
- [Structuring media library files into folders](#structuring-media-library-files-into-folders)
- [Configuring the Clean Azure storage cache scheduled task](#configuring-the-clean-azure-storage-cache-scheduled-task)

  [ ](https://docs.kentico.com/13/deploying-websites/running-xperience-on-microsoft-azure/configuring-azure-cdn.md)

## 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](https://docs.kentico.com/13/configuring-xperience/configuring-the-environment-for-content-editors/configuring-media-libraries.md#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](https://docs.kentico.com/13/configuring-xperience/scheduling-tasks.md). 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. 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).
3. **Edit** () the **Clean Azure storage cache** scheduled task.
4. Modify the **Period** or other [properties of the task](https://docs.kentico.com/13/configuring-xperience/scheduling-tasks/reference-scheduled-task-properties.md) 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](https://docs.kentico.com/13/configuring-xperience/reference-web-config-application-keys.md) 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:

```csharp

<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:

```csharp

<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):

```csharp

<add key="CMSAzureStorageCacheCleanerExcludedPaths" value="folder_name1;folder_name2"/>

```
