> ## Documentation Index
> Fetch the complete documentation index at: https://docs.omni.co/llms.txt
> Use this file to discover all available pages before exploring further.

# cache_policies - Model files

> Defines cache policies for the model.

Defines cache policies for the model. Each policy must have a `max_cache_age` parameter that defines the time limit for the policy.

Omni defaults to the following cache policy and filter suggestion retention period:

* **Default cache policy** - 6 hours; overridden with [`max_cache_age`](#param-max-cache-age)
* **Filter suggestion retention** - 30 days; overridden when [`filter_suggestions_must_obey_policy`](#param-filter-suggestions-must-obey-policy) is `true`
* **Omni Agent chat summary responses** - 30 days

**Note**: This parameter allows you to set defaults for the model, but caching policies can also be set at the dashboard level. Editing cache policies in a workbook model or query model effectively applies the policy to the associated dashboard.

Refer to the [Topics documentation](/modeling/topics) for information about setting topic-level cache policies.

## Syntax

```yaml theme={null}
cache_policies:
  <cache_policy_name>:
     max_cache_age: <0_seconds_to_30_days>
     filter_suggestions_must_obey_policy: true/false
```

## Properties

<ParamField path="cache_policies" type="string" required>
  A map of cache policy objects where each key is the name of a cache policy. Cache policy names must be unique.

  <Expandable title="cache_policies properties" defaultOpen="true">
    <ParamField path="cache_policy_name" type="string" required>
      A name that uniquely identifies the cache policy.

      <Expandable title="cache_policy_name properties" defaultOpen="true">
        <ParamField body="max_cache_age" type="string" required>
          Defines a rolling-window time limit for the cache policy. The limit is calculated using the timestamp when the cache entry was written, not a specific time of day.

          For example, if a query populates the cache at 9pm and `max_cache_age` is `24 hours`, users loading the dashboard at 8am the next morning will still see the 9pm result until 9pm that day.

          Accepted values must be between `0 seconds` and `30 days`. If a value exceeding `30 days` is entered Omni will default to the model's specified `default_cache_policy`. If a default policy isn't set, Omni's default policy of 6 hours will be used.

          <Tip>
            To guarantee fresh data at a specific time (for example, at the start of each business day), pair a longer cache policy with a scheduled dashboard run. The scheduler always bypasses the cache and repopulates it with fresh results. Refer to [Cache warming](/analyze-explore/performance/caching#cache-warming-preemptively-caching-data) for the full pattern.
          </Tip>
        </ParamField>

        <ParamField body="filter_suggestions_must_obey_policy" type="boolean" default="false">
          <Warning>
            This setting can't currently be removed if set, but it can be changed if needed.
          </Warning>

          Determines whether filter suggestions obey the cache policy. If `false`, filter suggestions will be retained for 30 days. Defaults to `false`.
        </ParamField>

        <ParamField body="default_cache_policy" type="string">
          Defines the default cache policy for the model.

          If set, the cache policy will be applied to all topics in the model and override Omni's default cache policy. Refer to the [Topics documentation](/modeling/topics) for information about setting topic-level cache policies.
        </ParamField>
      </Expandable>
    </ParamField>
  </Expandable>
</ParamField>

## Examples

```yaml title="Retain filter suggestions for 30 days" theme={null}
cache_policies:
  dont_cache_at_all:
    max_cache_age: 0 seconds
    filter_suggestions_must_obey_policy: false       # Retain filter suggestions for 30 days
```

```yaml title="Obey cache policy & retain for 24 hours" theme={null}
cache_policies:
  cache_for_a_day:
    max_cache_age: 24 hours
    filter_suggestions_must_obey_policy: true        # Obey cache policy & retain for 24 hours
```
