Skip to content
Back to skills

1 Use Caching Appropriately

ASecurity

Sub-skill of streamlit: 1. Use Caching Appropriately (+3).

  • 17 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 9, 2026
datapythongoperformance

Security analysis

A100/100

Scanned September 9, 2026

npx -y skills add vamseeachanta/workspace-hub --skill 1-use-caching-appropriately --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of 1 Use Caching Appropriately?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for 1 Use Caching Appropriately
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/vamseeachanta-1-use-caching-appropriately/badge)](https://www.skillsdirectory.com/skills/vamseeachanta-1-use-caching-appropriately)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: streamlit-1-use-caching-appropriately
description: 'Sub-skill of streamlit: 1. Use Caching Appropriately (+3).'
version: 1.0.0
category: data-analysis
type: reference
scripts_exempt: true
---

# 1. Use Caching Appropriately (+3)

## 1. Use Caching Appropriately


```python
# GOOD: Cache data loading
@st.cache_data
def load_data():
    return pd.read_csv("data.csv")

# GOOD: Cache resources (DB connections, models)
@st.cache_resource
def get_model():
    return load_model("model.pkl")

# AVOID: Caching with unhashable arguments
# Use _arg prefix to skip hashing
@st.cache_data
def process_data(_db_connection, query):
    return _db_connection.execute(query)
```


## 2. Organize Large Apps


```python
# utils/data.py
def load_data():
    pass

# utils/charts.py
def create_chart(df):
    pass

# app.py
from utils.data import load_data
from utils.charts import create_chart
```


## 3. Handle State Carefully


```python
# GOOD: Initialize state at the top
if "data" not in st.session_state:
    st.session_state.data = None

# GOOD: Use callbacks for complex updates
def on_filter_change():
    st.session_state.filtered_data = apply_filter(st.session_state.data)

st.selectbox("Filter", options, on_change=on_filter_change)
```


## 4. Optimize Performance


```python
# Use containers for layout stability
placeholder = st.empty()

# Batch widget updates in forms
with st.form("filters"):
    # Multiple widgets
    st.form_submit_button()

# Use columns for responsive layout
cols = st.columns([1, 2, 1])
```

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.