---
title: Setting cache dependencies
related:
  - https://docs.kentico.com/k10/configuring-kentico/optimizing-website-performance/configuring-caching.md
  - https://docs.kentico.com/k10/configuring-kentico/optimizing-website-performance/configuring-caching/debugging-cache.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).

Cache dependencies allow the application to automatically clear cached data when related objects are modified.

The system uses _**dummy cache keys**_ to create dependencies between cached data and other objects. Dummy keys are cache items without any data that represent objects or groups of objects. When an object is modified, the system "touches" the corresponding dummy keys, which causes the cache to delete all items that depend on the given dummy keys.

> **Info:** **Sample scenario**
>
> A page with the _/Products_ alias path contains a Repeater web part with [content caching](https://docs.kentico.com/k10/configuring-kentico/optimizing-website-performance/configuring-caching/caching-the-data-of-page-components.md) enabled. The repeater displays a list of products (pages) placed under the Products page. When a visitor requests the Products page, the repeater loads the list of products from the database, and stores the data in the content cache. The cached data has a dependency on the _**node|corporatesite|/products|childnodes**_ dummy key, which the system automatically creates. If a child page of the Products page is modified, the dummy key is touched, and the cache deletes the dependent data.

The following table shows which dummy cache keys are touched when objects are modified:

| Object type                       | Touched dummy keys                                                                                                                                                                                     | Sample dummy key values                                                                                                                                                                                                                                                           |
| --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Pages**<br>(content tree nodes) | node\|\|\|<br>node\|\|<br>nodeid\|<br>nodeid\|<br>documentid\|<br>documentid\|\|attachments<br>nodes\|\|\|all<br>nodeguid\|\|<br>**+ for all ancestors of the modified page:**<br>node\|\|\|childnodes | node\|corporatesite\|/home\|en-us<br>node\|corporatesite\|/home<br>nodeid\|12<br>nodeid\|34<br>documentid\|39<br>documentid\|39\|attachments<br>nodes\|corporatesite\|cms.menuitem\|all<br>nodeguid\|corporatesite\|a58ed488-5545-48d0- ...<br>node\|corporatesite\|/\|childnodes |
| **Objects**<br>(not pages)        | \|all<br>\|byid\|<br>\|byname\|<br>\|byguid\|<br>**Tip**: You can find the object type values in the **System** application on the **Object types** tab.                                               | cms.user\|all<br>cms.user\|byid\|53<br>cms.user\|byname\|administrator<br>cms.user\|byguid\|1ced44f3-f2fc- ...                                                                                                                                                                    |
| Metafiles                         | metafile\|                                                                                                                                                                                             | metafile\|1ced44f3-f2fc- ...                                                                                                                                                                                                                                                      |
| Page attachments                  | cms.attachment\|all<br>documentid\|<br>documentid\|\|attachments<br>attachment\|                                                                                                                       | cms.attachment\|all<br>documentid\|32<br>documentid\|32\|attachments<br>attachment\|1ced44f3-f2fc- ...                                                                                                                                                                            |
| Page relationships                | nodeid\|\|relationships                                                                                                                                                                                | nodeid\|5\|relationships                                                                                                                                                                                                                                                          |
| Forum attachments                 | forumattachment\|                                                                                                                                                                                      | forumattachment\|1ced44f3-f2fc- ...                                                                                                                                                                                                                                               |
| Avatars                           | avatarfile\|                                                                                                                                                                                           | avatarfile\|1ced44f3-f2fc- ...                                                                                                                                                                                                                                                    |
| Media files                       | mediafile\|<br>mediafile\|preview\|                                                                                                                                                                    | mediafile\|1ced44f3-f2fc- ...<br>mediafile\|preview\|1ced44f3-f2fc- ...                                                                                                                                                                                                           |
| Page templates                    | template\|                                                                                                                                                                                             | template\|12                                                                                                                                                                                                                                                                      |
| Custom table data records         | customtableitem.\|all<br>customtableitem.\|byid\|                                                                                                                                                      | customtableitem.customtable.sampletable\|all<br>customtableitem.customtable.sampletable\|byid\|2                                                                                                                                                                                  |

> **Info:** **Dependencies on form data records**
>
> The system currently does not touch any dummy cache keys when changes occur for data submitted via [forms](https://docs.kentico.com/k10/managing-website-content/forms.md).
>
> As a workaround, developers can prepare custom [event handlers](https://docs.kentico.com/k10/custom-development/handling-global-events.md) for [BizFormItemEvents](https://docs.kentico.com/k10/custom-development/handling-global-events/reference-global-system-events.md#bizformitemevents). Use the handler method to touch a custom cache key, and then enter the key into your cache dependencies. For example:
>
> ```csharp
>
> private void FormItem_InsertAfterHandler(object sender, BizFormItemEventArgs e)
> {
>     // Touches a custom cache key, for example: "customformdata|bizform.contactus"
>     CacheHelper.TouchKey("customformdata|" + e.Item.BizFormClassName);
> }
>
> ```

## Adding custom cache dependencies

You can set custom cache dependencies for the following types of cache:

- [Full output cache of pages](https://docs.kentico.com/k10/configuring-kentico/optimizing-website-performance/configuring-caching/caching-page-output.md) (add the **Output cache dependencies** web part onto the page)
- [Partial output cache of web parts or controls](https://docs.kentico.com/k10/configuring-kentico/optimizing-website-performance/configuring-caching/caching-page-output.md#caching-portions-of-the-page-output) (**Partial cache dependencies** property)
- [Content cache of web parts or controls](https://docs.kentico.com/k10/configuring-kentico/optimizing-website-performance/configuring-caching/caching-the-data-of-page-components.md) (**Cache dependencies** property)
- [Cached data in custom code](https://docs.kentico.com/k10/custom-development/caching-in-custom-code.md)

Create the dependencies by typing the names of **dummy cache keys** into the appropriate _Cache dependencies_ property. Each dummy key must be on a separate line when entering dependencies in the web part properties dialog. The system automatically clears the related cache when the specified dummy keys are touched (i.e. when the corresponding objects are modified).

### Examples

> **Info:** **Scenario**: You have a web part displaying information about users. You need to clear the web part's [partial output cache](https://docs.kentico.com/k10/configuring-kentico/optimizing-website-performance/configuring-caching/caching-page-output.md) whenever one of the user's data is modified.
>
> **Solution**: Add the **cms.user|all** dummy key into the web part's **Partial cache dependencies** property. The system touches this dummy key whenever the data of a user in the system changes.

> **Info:** **Scenario**: You have a web part displaying information about one specific user — the administrator (UserID is _53_, UserGuid is _849711D0-739D-412E-92B6-FE40EDCADC4A_). You need to clear the web part's [partial output cache](https://docs.kentico.com/k10/configuring-kentico/optimizing-website-performance/configuring-caching/caching-page-output.md) when the administrator's user account data is modified.
>
> **Solution**: Add any of the following dummy keys into the web part's **Partial cache dependencies** property:
>
> - cms.user|byid|53
> - cms.user|byname|administrator
> - cms.user|byguid|849711D0-739D-412E-92B6-FE40EDCADC4A

> **Info:** **Scenario**: You have a web part displaying a list of news articles. The web part loads the data from all _**CMS.News**_ pages on the website. The site's code name is _**NewsSite**_. You need to clear the web part's [partial output cache](https://docs.kentico.com/k10/configuring-kentico/optimizing-website-performance/configuring-caching/caching-page-output.md) when any of the news pages is updated.
>
> **Solution**: Add the **nodes|newssite|cms.news|all** dummy key into the web part's **Partial cache dependencies** property.
