React.cache() only works within one request. For data shared across sequential requests (user clicks button A then button B), use an LRU cache. Use when sequent
Cross-Request LRU Caching enables efficient data reuse across sequential user requests by storing recent query results in a limited-size, time-bound cache. Unlike React.cache(), which only caches within a single request, this skill leverages an LRU (Least Recently Used) cache to serve repeated data fetches without redundant database queries. It is particularly useful when multiple user interactions require the same data within a short timeframe, reducing latency and backend load.
This approach optimizes performance in environments like Vercel’s Fluid Compute, where multiple requests can hit the same function instance and share the cache. In contrast, traditional serverless setups that isolate each invocation may require external caches such as Redis to achieve cross-request persistence.
This skill is designed for performance marketers and growth leads managing web applications with dynamic user flows that trigger multiple dependent API calls. SEO and PPC operators working on landing pages with personalized content can also benefit by speeding up data delivery across user sessions. Additionally, agency strategists orchestrating complex multi-step funnels will find this useful to maintain consistent, fast user experiences without overloading backend systems.
It suits scenarios where users perform sequential actions—like clicking through different product options or account sections—that rely on overlapping data often queried multiple times within minutes.
Practitioners start by identifying data endpoints frequently requested in quick succession by the same user or session. Next, they implement an LRU cache with sensible size and time-to-live limits—for example, retaining up to 1000 entries with a 5-minute expiration—to balance memory use and freshness. The workflow continues by modifying data-fetching functions to first check the cache for existing entries before querying the database, returning cached results immediately if found.
Finally, performance is monitored to ensure cache hit rates effectively reduce backend calls without serving stale data, adjusting TTL or cache size as needed based on user behavior and system resource constraints.
How is this different from React.cache()? React.cache() only persists data within a single request, while LRU caching spans multiple requests in the same function instance. Can this be used in serverless environments? Yes, but it’s most effective where function instances are reused; otherwise, external caches like Redis are recommended. What cache parameters should I tune? Cache size and TTL depend on traffic patterns and data volatility; start with a few thousand entries and a 5-minute TTL, then optimize based on hit rate and memory usage.
Attach the Cross-Request LRU Caching skill to any Metaflow agent task that handles sequential user requests requiring shared data. The skill sets up an in-memory LRU cache within the function instance, automatically caching database calls during the task’s execution window. Expect faster response times on repeated queries and reduced backend load when users navigate through related endpoints. For detailed configuration and best practices, refer to the documentation on implementing caching within Metaflow tasks.
For broader context, see our roundup of claude skills for marketing, and read Claude Code workflows for marketing agencies for related setup guidance.