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

# Caching

> Configure Redis-backed caching for your Spree application to speed up database queries and template renders, with tips for cache keys and invalidation.

Caching improves performance by storing the results of expensive database queries and template renders in memory.

## Setting up Redis as Cache Store

Spree comes pre-configured to use Redis for caching in production. Just set the `REDIS_URL` environment variable — no gem installation or code changes needed.

```bash theme={"theme":"night-owl"}
REDIS_URL=redis://localhost:6379/0
```

When `REDIS_URL` is set, Spree automatically uses it for caching. When not set, it falls back to an in-memory cache store.

## Testing Locally

To enable caching in the development environment:

<CodeGroup>
  ```bash Spree CLI (Docker) theme={"theme":"night-owl"}
  spree rails dev:cache
  ```

  ```bash Without Spree CLI theme={"theme":"night-owl"}
  bin/rails dev:cache
  ```
</CodeGroup>

You will need to restart your web server after this.
