What problem does it solve?
Streamlit apps often become slow or waste resources because every interaction can trigger a full-app rerun and heavy computations reload on each user action; this Skill explains how to avoid unnecessary reruns, unbounded memory growth, and shared-resource mutation to keep apps responsive and stable.
Core Features & Use Cases
- Caching patterns: Guidance on when and how to use @st.cache_data for computed data and @st.cache_resource for connections and large non-serializable objects, including TTL, max_entries, and on_release cleanup.
- Fragment isolation & batching: Use @st.fragment and st.form to confine reruns to small UI pieces or batch inputs so typing and unrelated interactions do not retrigger expensive work.
- Conditional rendering & large-data strategies: Techniques for rendering heavy content only when needed (segmented controls, toggles), pre-computing work in DB/jobs, sampling for exploration, and when to use resource caching for extremely large datasets.
- Multithreading and safety: Patterns for background fetching without Streamlit calls in threads and warnings against mutating cached shared resources to prevent cross-user side effects.
- Use Case: Convert a slow live dashboard that recomputes charts on every click into a responsive UI by caching raw data, isolating auto-refreshing metrics in fragments, and conditionally loading heavy charts only when requested.
Quick Start
Use this skill to identify and apply caching, fragments, conditional rendering, and form batching to reduce reruns and memory usage in your Streamlit app.