# Clearing tag history cache

**URL:** <https://forum.inductiveautomation.com/t/clearing-tag-history-cache/95784>\
**Category:** Ignition\
**Created:** [September 10, 2024, 10:02am UTC](https://forum.inductiveautomation.com/t/clearing-tag-history-cache/95784 "2024-09-10T10:02:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [September 10, 2024, 10:02am UTC](https://forum.inductiveautomation.com/t/clearing-tag-history-cache/95784/1 "2024-09-10T10:02:28Z")

</div>

Hello folks,

The doc page for `storeTagHistory` says:

> Note that the Tag History system does cache tag data. Thus, if this function is called, the tag path and tag id are cached until the history provider or gateway are restarted. This means manually removing the tag from the sqlth\_te table, and then calling this function again with the same path will **not** re-populate the tag execution table (especially so when working purely with virtual tag paths). Instead, **the cache must first be cleared** , and then a new entry will be added the next time this function is called.

Note the bold part. Alright, but how do I do this ?  
I'm running tests for something I'm developing and I need to clear the tables to rerun them, but I can't figure out how to clear the cache.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [September 10, 2024, 10:49am UTC](https://forum.inductiveautomation.com/t/clearing-tag-history-cache/95784/2 "2024-09-10T10:49:05Z")

</div>

I believe, the first part tells you.

> Thus, if this function is called, the tag path and tag id are **cached until the history provider or gateway are restarted.**

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [September 10, 2024, 11:38am UTC](https://forum.inductiveautomation.com/t/clearing-tag-history-cache/95784/3 "2024-09-10T11:38:50Z")

</div>

I don't want to have to restart the gateway every time.

Is there a better way than disabling then re-enabling the history provider ?  
Ideally I'd like to do this with a function call.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [September 10, 2024, 11:57am UTC](https://forum.inductiveautomation.com/t/clearing-tag-history-cache/95784/4 "2024-09-10T11:57:49Z")

</div>

You can get a reference to the provider through a `GatewayContext.getTagHistoryManager().getTagHistoryProvider("ProviderName")`, and call the `startup()` and `shutdown()` methods on it.

I don't know of any public facing method for clearing the cache manually.

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [September 10, 2024, 12:29pm UTC](https://forum.inductiveautomation.com/t/clearing-tag-history-cache/95784/5 "2024-09-10T12:29:32Z")

</div>

I can work with that. Thanks !
