St.cache_data
st.cache_data is a Streamlit decorator that caches data-returning function results and reuses them across reruns when inputs are unchanged.
Build Python Web Apps with Streamlit
st.cache_data is a Streamlit decorator or caching mechanism that stores function results and reuses them across reruns when inputs remain unchanged.
- How it is used
- Improves dashboard performance by reusing slow data-loading results across reruns and page refreshes.
- How deep it goes
- Defines decorator-based caching and demonstrates ttl and spinner options, but does not detail cache invalidation internals.
- Examples
- Uses a cached load_data function that reads sales data with pandas read_csv and displays loading feedback.
- What you can do after
- Apply it via the @st.cache_data decorator to cache slow data-loading functions and configure expiration or feedback.
Read how Build Python Web Apps with Streamlit explains st.cache_data →
The Well-Grounded Data Analyst
A Streamlit decorator that caches data-returning function results to avoid repeated computation or loading.
- How it is used
- Speeds interactive Streamlit proof-of-concept apps by preventing repeated loading of unchanged datasets.
- How deep it goes
- Explains decorator placement and shows cached helper calls, but does not detail cache invalidation or storage internals.
- Examples
- Demonstrates cached price data, county lists, and county ridgeplot data in a Wales house-price explorer.
- What you can do after
- Operate/configure Streamlit data loading by decorating helper functions whose results should persist across user actions.
Read how The Well-Grounded Data Analyst explains st.cache_data →
Related concepts
- Streamlitused by · Streamlit is an open-source Python framework for building interactive web applications, particularly for data and machine-learning applications.
- cachingimplements · Caching is the practice of storing reusable data or computation results so later access can avoid repeating retrieval or computation.
- expiration dateconfigured by · An expiration setting specifies when, or after what duration, an item, data, resource, or right ceases to be valid, available, or retained.
- decoratorkind of · A decorator is a programming-language construct that adds metadata or behavior to, or transforms, a program declaration, often a function or class.
- reruncontrasts with · A Streamlit development setting that automatically reruns an app when its source code changes.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

