# How does script caching work when the script is updated?

**URL:** <https://discuss.elastic.co/t/how-does-script-caching-work-when-the-script-is-updated/210199>\
**Category:** Elasticsearch\
**Created:** [December 2, 2019, 2:30pm UTC](https://discuss.elastic.co/t/how-does-script-caching-work-when-the-script-is-updated/210199 "2019-12-02T14:30:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![brabster](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/brabster/32/58641_2.png) [@brabster](https://discuss.elastic.co/u/brabster)\
**Post date:** [December 2, 2019, 2:30pm UTC](https://discuss.elastic.co/t/how-does-script-caching-work-when-the-script-is-updated/210199/1 "2019-12-02T14:30:19Z")

</div>

Does Elasticsearch recognise that a previously cached script has been updated, and replace the cache entry with the new script compilation?

I've seen code that manages script caching client-side, explicitly uploading new copies of a script when it changes. I've been looking at [https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting-using.html#modules-scripting-using-caching](https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting-using.html#modules-scripting-using-caching) and I'm not sure whether this explicit behaviour is necessary - and if it is, why it isn't just handled by Elasticsearch itself.

Should I manage script updates with explicit code? Or is it handled better by Elasticsearch?

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [December 2, 2019, 2:46pm UTC](https://discuss.elastic.co/t/how-does-script-caching-work-when-the-script-is-updated/210199/2 "2019-12-02T14:46:48Z")

</div>

This is taken care of. The internal cache will create a new cache key when the script is updated and use that one (allowing the old entry to expire over time or due to the cache being bounded by size and its LRU policy).

---

<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:** [December 30, 2019, 2:46pm UTC](https://discuss.elastic.co/t/how-does-script-caching-work-when-the-script-is-updated/210199/3 "2019-12-30T14:46:53Z")

</div>

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