# @st.cache\_data Behavior issue

**URL:** <https://discuss.streamlit.io/t/st-cache-data-behavior-issue/64422>\
**Category:** Using Streamlit\
**Tags:** cache, streamlit-cloud, discussion\
**Created:** [March 11, 2024, 2:35pm UTC](https://discuss.streamlit.io/t/st-cache-data-behavior-issue/64422 "2024-03-11T14:35:37Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Snow\_Yoo](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/snow_yoo/32/51149_2.png) [@Snow\_Yoo](https://discuss.streamlit.io/u/Snow_Yoo)\
**Post date:** [March 11, 2024, 2:35pm UTC](https://discuss.streamlit.io/t/st-cache-data-behavior-issue/64422/1 "2024-03-11T14:35:37Z")

</div>

Hello,  
I would like to know if there is a problem with “@st.cache\_data”, these 2 last days, I’ve noticed that functions with “@st.cache\_data” decorator are no longer cached correctly and rerun as if the cache was at 0(ttl=0s).

For other information :

- I have noticed this behavior on the apps deployed on the streamlit community cloud, and when i run the app locally, i got this eror message :

```auto
streamlit\util.py:227: RuntimeWarning:

coroutine 'expire_cache' was never awaited

```

- I haven’t changed my code for a while, and here is how i decoracte the functions :

```auto
@st.cache_data
def function(parameter1, parameter2):
    ...code

```

Thank you for your help !

---

<div class="post-metadata">

**Author:** ![tonykip](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/tonykip/32/45167_2.png) [@tonykip](https://discuss.streamlit.io/u/tonykip)\
**Post date:** [March 11, 2024, 4:47pm UTC](https://discuss.streamlit.io/t/st-cache-data-behavior-issue/64422/2 "2024-03-11T16:47:44Z")

</div>

Hi @Snow_Yoo,

Thanks for bringing this up.

Can you share some of the apps on Community Cloud that you’re seeing the issues with caching?

---

<div class="post-metadata">

**Author:** ![Snow\_Yoo](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/snow_yoo/32/51149_2.png) [@Snow\_Yoo](https://discuss.streamlit.io/u/Snow_Yoo)\
**Post date:** [March 11, 2024, 5:15pm UTC](https://discuss.streamlit.io/t/st-cache-data-behavior-issue/64422/3 "2024-03-11T17:15:55Z")

</div>

hello thank you for your reply, i cannot share this app because it’s a private one for teamwork, but here is a eror message i have on the Manage app logs :

```auto
/home/adminuser/venv/lib/python3.9/site-packages/streamlit/util.py:227: RuntimeWarning: coroutine 'expire_cache' was never awaited

  pass

RuntimeWarning: Enable tracemalloc to get the object allocation traceback

```

This app is continuously loading and reloading the main function. I have only a side bar with a spinner that keeps running without stopping, displaying messages like: 'Running `get_function...` '"

---

<div class="post-metadata">

**Author:** ![Girish](https://avatars.discourse-cdn.com/v4/letter/g/e36b37/32.png) [@Girish](https://discuss.streamlit.io/u/Girish)\
**Post date:** [March 12, 2024, 5:03am UTC](https://discuss.streamlit.io/t/st-cache-data-behavior-issue/64422/4 "2024-03-12T05:03:02Z")

</div>

Hi, Even I am facing the same issue. Any solution?

---

<div class="post-metadata">

**Author:** ![williamcerdelli](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/williamcerdelli/32/36755_2.png) [@williamcerdelli](https://discuss.streamlit.io/u/williamcerdelli)\
**Post date:** [March 12, 2024, 5:12am UTC](https://discuss.streamlit.io/t/st-cache-data-behavior-issue/64422/5 "2024-03-12T05:12:12Z")

</div>

I am getting the same error

---

<div class="post-metadata">

**Author:** ![Kero](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/kero/32/31922_2.png) [@Kero](https://discuss.streamlit.io/u/Kero)\
**Post date:** [March 12, 2024, 7:54am UTC](https://discuss.streamlit.io/t/st-cache-data-behavior-issue/64422/6 "2024-03-12T07:54:32Z")

</div>

I am getting the same error with @st.cache\_resource. Updating to 1.32.0 breaks my application because of this.

---

<div class="post-metadata">

**Author:** ![twarr58](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/twarr58/32/40026_2.png) [@twarr58](https://discuss.streamlit.io/u/twarr58)\
**Post date:** [March 12, 2024, 8:55am UTC](https://discuss.streamlit.io/t/st-cache-data-behavior-issue/64422/7 "2024-03-12T08:55:36Z")

</div>

for the time being go and use `cachetools.func.ttl_cache` as workaround.  
functionality for user should be alsmost the same, except that progress animation will be not showing.

and yes, after updating to `1.32` iam facing same issue.

---

<div class="post-metadata">

**Author:** ![pynomaly](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/pynomaly/32/30743_2.png) [@pynomaly](https://discuss.streamlit.io/u/pynomaly)\
**Post date:** [March 12, 2024, 1:12pm UTC](https://discuss.streamlit.io/t/st-cache-data-behavior-issue/64422/8 "2024-03-12T13:12:30Z")

</div>

Same issue here, after updating to `1.32`:

```auto
streamlit/util.py:227: RuntimeWarning:

coroutine 'expire_cache' was never awaited

```

---

<div class="post-metadata">

**Author:** ![thedoc](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/thedoc/32/40052_2.png) [@thedoc](https://discuss.streamlit.io/u/thedoc)\
**Post date:** [March 12, 2024, 7:25pm UTC](https://discuss.streamlit.io/t/st-cache-data-behavior-issue/64422/9 "2024-03-12T19:25:07Z")

</div>

Im also getting this:

streamlit/util.py:227: RuntimeWarning: coroutine ‘expire\_cache’ was never awaited  
pass  
RuntimeWarning: Enable tracemalloc to get the object allocation traceback

But im seeing this warning after integrating asyncio and im using @st.cache\_data decorator. it might be due to an incompatibility or incorrect usage of asynchronous functions with Streamlit’s cache.

But it doesn’t directly affect the functionality of my app. Just slowing initial loading.

---

<div class="post-metadata">

**Author:** ![gaLezki](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/galezki/32/40061_2.png) [@gaLezki](https://discuss.streamlit.io/u/gaLezki)\
**Post date:** [March 12, 2024, 8:39pm UTC](https://discuss.streamlit.io/t/st-cache-data-behavior-issue/64422/10 "2024-03-12T20:39:14Z")

</div>

Same problem here. Didn’t occur before I updated from 1.31.1 to 1.32.0. Doesn’t happen now after I reverted back to 1.31.1. I don’t need anything from 1.32.0 so I’ll just stick to 1.31.1 for now.

---

<div class="post-metadata">

**Author:** ![lukasmasuch](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/lukasmasuch/32/52605_2.png) [@lukasmasuch](https://discuss.streamlit.io/u/lukasmasuch)\
**Post date:** [March 12, 2024, 9:58pm UTC](https://discuss.streamlit.io/t/st-cache-data-behavior-issue/64422/11 "2024-03-12T21:58:20Z")

</div>

We have an issue with the `1.32.0` version which causes the mentioned `RuntimeWarning` and our CPU utilization to max out ☹ The `1.32.1` patch will likely fix that, but it needs a bit further evaluation.

---

<div class="post-metadata">

**Author:** ![axtolm](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/axtolm/32/40048_2.png) [@axtolm](https://discuss.streamlit.io/u/axtolm)\
**Post date:** [March 13, 2024, 1:01am UTC](https://discuss.streamlit.io/t/st-cache-data-behavior-issue/64422/12 "2024-03-13T01:01:55Z")

</div>

Hi, I have the same problem with @st.cache\_data in 1.32.

---

<div class="post-metadata">

**Author:** ![tipani86](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/tipani86/32/24403_2.png) [@tipani86](https://discuss.streamlit.io/u/tipani86)\
**Post date:** [March 13, 2024, 1:44am UTC](https://discuss.streamlit.io/t/st-cache-data-behavior-issue/64422/13 "2024-03-13T01:44:11Z")

</div>

That was fast: [Revert "Expire session storage cache on an async timer (#8083)" (#8281) · streamlit/streamlit@b6f71f9 · GitHub](https://github.com/streamlit/streamlit/commit/b6f71f94e474e8cd747ace7c9e94820c1dda0061)

Thanks for pushing out 1.32.1 so quickly.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/streamlit/original/3X/c/f/cf4c2ee0d938358f82448c5fe4b9c3c91d7ce19c.svg) [@system](https://discuss.streamlit.io/u/system)\
**Post date:** [September 9, 2024, 1:44am UTC](https://discuss.streamlit.io/t/st-cache-data-behavior-issue/64422/14 "2024-09-09T01:44:19Z")

</div>

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