From 9b2af5d4eceadfe498ae1d5ac0bb0a8c96410925 Mon Sep 17 00:00:00 2001
From: Pandiyan <147422749+S-PANDIYAN@users.noreply.github.com>
Date: Thu, 1 Jan 2026 21:29:16 +0530
Subject: [PATCH 1/2] Clarify st.cache_resource requirements in
documentationDocs: clarify picklable requirement for st.cache_resource
Clarifies that `st.cache_resource` requires pickle-able objects in addition
to being hashable, aligning the documentation with current caching behavior
and addressing confusion reported in streamlit/streamlit#13480.
---
.../api-reference/caching-and-state/cache-resource.md | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/content/develop/api-reference/caching-and-state/cache-resource.md b/content/develop/api-reference/caching-and-state/cache-resource.md
index 4cc88b727..40d720966 100644
--- a/content/develop/api-reference/caching-and-state/cache-resource.md
+++ b/content/develop/api-reference/caching-and-state/cache-resource.md
@@ -11,6 +11,15 @@ This page only contains information on the `st.cache_resource` API. For a deeper
+
+
+Due to the current implementation of Streamlit’s caching mechanism, objects passed to
+`st.cache_resource` must be **pickle-able** (serializable) in addition to being
+**hashable**. Objects that contain non-pickleable elements (such as functions)
+may raise errors like `TypeError: cannot pickle 'function' object`.
+
+
+
From e2ab141147ca7783138963a264ac4aebfafd9ac7 Mon Sep 17 00:00:00 2001
From: Pandiyan <147422749+S-PANDIYAN@users.noreply.github.com>
Date: Tue, 6 Jan 2026 12:41:23 +0530
Subject: [PATCH 2/2] Update cache-resource.md
Docs: clarify why st.cache_resource requires pickleable objects
---
.../caching-and-state/cache-resource.md | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/content/develop/api-reference/caching-and-state/cache-resource.md b/content/develop/api-reference/caching-and-state/cache-resource.md
index 40d720966..c803ab87b 100644
--- a/content/develop/api-reference/caching-and-state/cache-resource.md
+++ b/content/develop/api-reference/caching-and-state/cache-resource.md
@@ -15,8 +15,17 @@ This page only contains information on the `st.cache_resource` API. For a deeper
Due to the current implementation of Streamlit’s caching mechanism, objects passed to
`st.cache_resource` must be **pickle-able** (serializable) in addition to being
-**hashable**. Objects that contain non-pickleable elements (such as functions)
-may raise errors like `TypeError: cannot pickle 'function' object`.
+**hashable**.
+
+Streamlit’s rerun model relies on **content-based hashing** to determine when cached
+values can be reused across reruns. This hashing mechanism is implemented using
+Python’s pickling system (via the `__reduce__()` method). As a result, cached objects
+must be pickle-able.
+
+Objects that contain non-pickle-able elements (such as functions, lambdas, or open
+file handles) may raise errors such as:
+
+`TypeError: cannot pickle 'function' object`