Should API call be cached when designed to only run once?

Hello, I’m wondering if there’s any possible reason to cache an API call in a Streamlit app if it is already designed to perform the API call only once per user session? Here is python pseudo-code to demonstrate what I mean by this scenario.

...
if "external_data" not in st.session_state:
    api_result = make_the_api_call()
    cleaned_data = turn_api_result_into_dataframe()
    st.session_state["external_data"] = cleaned_data
...

One possible reason is not having to actually make the same call in each session.

Hi @Goyo - can you clarify that a bit more? It sounds like you’re saying caching the response of the API call would allow it to be used across multiple sessions? The logic I shared above already ensures the API call would only be made once per session.

I think you got it right.