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

# Invalidate Cache

> Clear cached transformation variants without deleting originals

**`DELETE /invalidate/{path}` is self-hosted only.** On Cloud, clear a single asset by deleting and re-uploading it, or purge everything with `POST /storage/cache/clear`, which works on both.

Clears the cached transformation variants of one file. The original is not touched.

```
DELETE /invalidate/{path}
```

```bash theme={null}
curl -X DELETE https://media.example.com/invalidate/photos/portrait.jpg \
  -H "Authorization: Bearer <api_key>"
```

**Auth:** API Key required

Three caches are cleared for the file: the local cache of variants stored on disk, the cloud cache of variants stored in S3-compatible storage if configured, and the in-memory cache of metadata entries.

## Path parameters

| Param | Type | Required | Description |
| - | - | - | - |
| `path` | string | yes | Path to the file relative to the storage root, e.g. `photos/portrait.jpg`. |

## Response

```json theme={null}
{
  "success": true,
  "message": "Cache invalidated successfully",
  "details": {
    "localCacheFilesDeleted": 3,
    "cloudCacheFilesDeleted": 0
  }
}
```

| Field | Type | Description |
| - | - | - |
| `success` | boolean | `true` only when nothing failed |
| `message` | string | Human-readable result summary |
| `details` | object | Counters and errors, below |

* `localCacheFilesDeleted`, number: cached transformation variants removed from local disk
* `cloudCacheFilesDeleted`, number: cached transformation variants removed from cloud storage
* `errors`, string\[]: non-fatal errors encountered during cleanup. Only present when some steps failed

`success` is computed as `errors.length === 0`, so a single non-fatal cleanup error makes it `false` even though the variants that could be removed were removed. Read `details.errors` to see what actually happened.

**Status codes:** `200` success (or partial) · `400` path missing · `500` error

## Clear the entire cache

```
POST /storage/cache/clear
```

```bash theme={null}
curl -X POST https://cdn.openinary.dev/storage/cache/clear \
  -H "Authorization: Bearer <api_key>"
```

Removes every cached transformation variant on the instance, local and cloud, for every file. Takes no parameters and no body. Auth is an API key, or a dashboard session cookie.

> [!WARNING]
>
> This purges the whole cache, not one file's variants. Every transformation is
> regenerated on its next request, so the first hit on each URL pays full
> processing cost again. On an instance serving many variants that is a
> significant, self-inflicted load spike. Reach for
> `DELETE /invalidate/{path}` unless you genuinely mean all of it.

```json theme={null}
{
  "success": true,
  "message": "Cache cleared successfully",
  "details": {
    "localCacheFilesDeleted": 128,
    "cloudCacheFilesDeleted": 64
  }
}
```

**Status codes:** `200` success · `500` a cache backend failed

## Related

> [card] [Delete File](https://docs.openinary.dev/api-reference/storage/delete.md)
>
> Permanently remove a file and all its cached variants.

> [card] [Transform](https://docs.openinary.dev/api-reference/media/transform.md)
>
> Apply transformations, results are cached automatically.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.