# Painless Script Caching Question

**URL:** <https://discuss.elastic.co/t/painless-script-caching-question/259361>\
**Category:** Elasticsearch\
**Created:** [December 22, 2020, 10:14am UTC](https://discuss.elastic.co/t/painless-script-caching-question/259361 "2020-12-22T10:14:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arthur\_Zheng](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/arthur_zheng/32/78031_2.png) [@Arthur\_Zheng](https://discuss.elastic.co/u/Arthur_Zheng)\
**Post date:** [December 22, 2020, 10:14am UTC](https://discuss.elastic.co/t/painless-script-caching-question/259361/1 "2020-12-22T10:14:17Z")

</div>

We are using es 7.1. We have an error “Too many dynamic script compilations within”。

It can be fixed by increase some params：  
script.context.$CONTEXT.max\_compilations\_rate

My question is ：  
Es 7.1 Supports a monitoring metric, can see the script caching evictions.  
This is result:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/a/5/a5cc916d0ae077b5cb9c44a82a47931b6c54701e.png)

according this:

All scripts are cached by default so that they only need to be recompiled when updates occur. By default, scripts do not have a time-based expiration, but you can change this behavior by using the `script.cache.expire` setting.

the scripts caching ttl is infinite,so it will evict by limit,but from the result, we dont't see it reach limit.

So what is the compilations and cache\_evictions mean? \* What other situations would clean up this cache?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [January 19, 2021, 10:14am UTC](https://discuss.elastic.co/t/painless-script-caching-question/259361/2 "2021-01-19T10:14:23Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
