Skip to main content
Loading page…
Python Mastery
Chapter 47
Lesson 3 of 4
State & Caching
Contents
Notes
Tutor
Concept
Why Plain Variables Don't Survive Reruns
Loading activity…
Previous
1 / 8
Continue
Contents
Notes
Discussion
Tutor
20 min
8 activities
0 of 8 done
In this lesson
1
Why Plain Variables Don't Survive Reruns
2
st.session_state — Persisting Values Across Reruns
3
@st.cache_data vs @st.cache_resource
4
Caching a Data Load Function
5
Forms: Batch Input to Reduce Reruns
6
Cache Decorator Choice
7
Correct Order for Session State Pattern
8
cache_data vs cache_resource
Objectives
Learner can explain why top-level variables reset on every rerun
Learner can persist values across reruns using st.session_state
Learner can apply @st.cache_data to cache data-loading functions
Learner can distinguish @st.cache_data from @st.cache_resource
Learner can batch multiple inputs with st.form to avoid excessive reruns
Further reading
Streamlit documentation
Chapter 47 · Data Apps with Streamlit
Your First Streamlit App
Widgets & Interactivity
State & Caching
Build a Data Dashboard
Previous: Widgets & Interactivity
Next: Build a Data Dashboard