Controlling Data Freshness in Streamlit with st.cache_data TTL
Avoid re-running expensive queries on every Streamlit interaction by using st.cache_data with a tuned TTL and hashable arguments.
ReadMeFeed / Community knowledge
Real questions. Useful conversations. Find the people who know your stack.
Avoid re-running expensive queries on every Streamlit interaction by using st.cache_data with a tuned TTL and hashable arguments.
Learn why Streamlit widgets revert to defaults and how to persist selections using st.session_state with a step‑by‑step diagnostic guide.
Learn how to use @st.cache_data to eliminate redundant computations in Streamlit apps, including practical examples of TTL configuration and the critical difference between data and resource caching.
Stop the frustrating lag of script reruns. Learn how to use @st.cache_data to optimize data loading and API calls in Streamlit for a snappier user experience.
A practical diagnostic guide for Streamlit @st.cache_data problems: unexpected recomputation, stale data, unhashable errors and memory growth, with ordered checks, fixes and escalation criteria.
When building a Streamlit app you’ll often need to reuse expensive work. This guide walks you through the four caching options – st.cache_data, st.cache_resource, st.session_state, and no caching – and shows how to pick the right one for multi‑user deployments, memory limits, and per‑user isolation.
Streamlit reruns your script on every interaction. Pick st.cache_data for serializable results and st.cache_resource for live connections and models—here is how to decide.
Streamlit reruns your entire script on every interaction. Learn how to diagnose why variables reset, and how st.session_state, caching, and widget keys fix stale state.
An architecture note on st.session_state: what it guarantees, where the trust and memory boundaries sit, how to verify behavior, and when to move persistence elsewhere.