---
title: Cleaning up unused chat data
---

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

In order to minimize the amount of storage space that Chat data consumes, it incorporates a set of scheduled tasks, which delete old and inactive records on a regular basis.

## Delete old chat records

This scheduled task deletes chat messages, rooms, and anonymous users which haven't logged any activity for the amount of time specified in settings. The age of the data that is to be deleted can be specified in **Settings -> Community -> Chat -> Delete chat history older than (days)**.

The order of performed deleting operations is as follows:

1. **Delete messages** - messages that were sent earlier than the specified amount of time.
2. **Delete rooms** - rooms that meet all of the following criteria will be deleted:
   1. is private
   2. contains no messages
   3. was created earlier than the specified amount of time
   4. doesn't contain any registered (non-anonymous) user that has elevated room permissions
   5. doesn't contain any anonymous user that has been on-line in the room during specified amount of time
3. **Delete users** - users meeting all of the following conditions will be deleted:
   1. haven't sent any message in the specified amount of time
   2. haven't been on-line in the specified amount of time

## Clean chat on-line users

This scheduled task removes anonymous users who stopped sending pings to the server without going off-line (e.g. their connection was interrupted or they simply closed the browser window).

## Clean chat rooms scheduled to delete

When you delete a room, it becomes disabled and scheduled to be deleted instead of being physically deleted from the database right away.

This scheduled task is by default executed once a day to delete the rooms marked for deletion.

This behavior ensures that users present in such room have a chance to get notified about the fact that the room they are in is getting deleted.
