> For the complete documentation index, see [llms.txt](https://ciusji.gitbook.io/spotrix/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ciusji.gitbook.io/spotrix/configuration/caching.md).

# Caching

Spotrix uses [Flask-Caching](https://flask-caching.readthedocs.io/) for caching purposes. Flask-Caching supports various caching backends, including Redis (recommended), Memcached, SimpleCache (in-memory), or the local filesystem. [Custom cache backends](https://flask-caching.readthedocs.io/en/latest/#custom-cache-backends) are also supported.

Caching can be configured by providing a dictionaries in `spotrix_config.py` that comply with [the Flask-Caching config specifications](https://flask-caching.readthedocs.io/en/latest/#configuring-flask-caching).

The following cache configurations can be customized in this way:

* Dashboard filter state: FILTER\_STATE\_CAHCE\_CONFIG **`required`**
* Explore chart from data: EXPLORE\_FROM\_DATA\_CACHE\_CONFIG **`required`**
* Metadata cache: CACHE\_CONFIG **`optional`**
* Charting data required from datasets: DATA\_CACHE\_CONFIG **`optional`**

For example, to configure the filter state cache using redis:

```python
FILTER_STATE_CACHE_CONFIG = {
    'CACHE_TYPE': 'RedisCache',
    'CACHE_DEFAULT_TIMEOUT': 86400,
    'CACHE_KEY_PREFIX': 'spotrix_filter_cache',
    'CACHE_REDIS_URL': 'redis://localhost:6379/0'
}
```
