Using Streamlit

Hello Guys,

I’m new to Streamlit . I’m developing a small data app and I cached back end REST-API responses by using @st.cache. The problem here is I’m using caching.clear_cache() to clear the cache when a page is refreshed but it is also clearing the @st.cache responses when i’m doing something on the page.
With out caching.clear_cache() method , it is absolutely working fine.
Is there a way to resolve this issue ?
Please let me know if you need more info.

Hi @Venky -

Streamlit refreshes the script on each interaction, so the behavior you are seeing is intended. Could you be a bit more specific about your use case? Is there a better way to determine whether to cache the API calls than just having a page refresh?

Best,
Randy

Yes @randyzwitch, Is there a better way to determine whether to cache the API calls than just having a page refresh ?

That’s not a question I can answer, that’s your business logic :slight_smile:

Why are you clearing the cache? What is the expected life of the information behind your API calls?

Thanks for your quick response @randyzwitch,
I’m confused initially but I’m good now. I just implemented business logic and added ttl.