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

# Caching

This page was last updated for version v1.2.0

## Description

For better optimization, we added an option that calculates and caches all mathematical equations when the effect is loaded.

The best use case for "caching" is when all mathematical equations always yield the same value. For example, if your mathematical equation does not have dynamic variables such as random variables or a player's position, you can enable this feature.

{% hint style="info" %}
You'll get a warning message on console if your effect has nothing to cache.
{% endhint %}

## Example

{% tabs %}
{% tab title="effects.yml" %}

```yml
effects:
  rainbow-flag:
    display-name: "%rainbow-flag%"
    color-animation: "rainbow"
    permission: "%rainbow-effects%"
    variables: [ 'r', 'x' ]
    enable-caching: true
    interval: 1
    on-tick:
      elytra:
        event: ELYTRA
        times: 16
        scripts:
          - var r={PI}*{i}/16
          - var x=cos({r})
          - particle [effect=minecraft:dust,direction=true,pos={x={x};y=-0.5},amount=10,origin=head*-1.25,color={name=rainbow;speed=0.075}]
```

{% endtab %}
{% endtabs %}
