> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hopx.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Cache

> Complete guide to cache management in HopX sandboxes - statistics, clearing, and optimization. Learn how to view cache statistics, clear execution cache, optimize cache usage, and monitor cache performance. Manage cache for improved execution speed and resource efficiency. Includes Python and JavaScript SDK examples and REST API endpoints.

Manage execution cache in HopX sandboxes for performance optimization. This hub covers cache statistics, clearing, and best practices.

## Related

* [CLI System Commands](/cli/commands/system) - System operations from CLI

## What You'll Learn

* How to view cache statistics
* How to clear execution cache
* How to optimize cache usage
* How to monitor cache performance
* Best practices for cache management

## Cache Management Overview

| Operation                                         | SDK Method              | API Endpoint        |
| ------------------------------------------------- | ----------------------- | ------------------- |
| **[Statistics](/core-concepts/cache/statistics)** | `sandbox.cache.stats()` | `GET /cache/stats`  |
| **[Clearing](/core-concepts/cache/clearing)**     | `sandbox.cache.clear()` | `POST /cache/clear` |

## Core Concepts

### Cache Statistics

View cache statistics including hit rate and cached items.

* **[Cache Statistics](/core-concepts/cache/statistics)** - View cache statistics
* **SDK**: [Python: sandbox.cache.stats()](/sdk/python/cache#stats) | [JavaScript: sandbox.cache.stats()](/sdk/javascript/cache#stats)
* **API**: [GET /cache/stats](/api/vm-agent/get-cache-stats)

### Clearing Cache

Clear execution cache to free memory or force re-execution.

* **[Clearing Cache](/core-concepts/cache/clearing)** - Clear execution cache
* **SDK**: [Python: sandbox.cache.clear()](/sdk/python/cache#clear) | [JavaScript: sandbox.cache.clear()](/sdk/javascript/cache#clear)
* **API**: [POST /cache/clear](/api/vm-agent/clear-cache)

## SDK Reference

### Python SDK

Complete reference for Python cache operations.

* **[Cache Module](/sdk/python/cache)** - Complete cache API
  * `cache.stats()` - Get cache statistics
  * `cache.clear()` - Clear cache

### JavaScript SDK

Complete reference for JavaScript/TypeScript cache operations.

* **[Cache Module](/sdk/javascript/cache)** - Complete cache API
  * `cache.stats()` - Get cache statistics
  * `cache.clear()` - Clear cache

## API Reference

### VM Agent API

REST API endpoints for cache management.

* **[VM Agent API Overview](/api/vm-agent/overview)** - API overview
* **[Get Cache Statistics](/api/vm-agent/get-cache-stats)** - `GET /cache/stats` - Get cache stats
* **[Clear Cache](/api/vm-agent/clear-cache)** - `POST /cache/clear` - Clear cache

## Quick Start

If you're new to cache management, start here:

1. **[Cache Statistics](/core-concepts/cache/statistics)** - View cache performance
2. **[Clearing Cache](/core-concepts/cache/clearing)** - Clear cache when needed

## Related Topics

* **[Code Execution](/core-concepts/code-execution/synchronous)** - Cache affects code execution
* **[Observability](/core-concepts/observability/metrics)** - Monitor cache metrics
* **[Sandboxes](/core-concepts/sandboxes/managing-state)** - Cache persists across state changes

## Next Steps

* Learn about [Cache Statistics](/core-concepts/cache/statistics) for monitoring
* Explore [Clearing Cache](/core-concepts/cache/clearing) for optimization
* Review [Code Execution](/core-concepts/code-execution/synchronous) to understand cache impact
* Check out [Observability](/core-concepts/observability/metrics) for performance monitoring
