---
name: "up.cache.evict"
area: "API"
kind: "JavaScript function"
parent: "up.network module"
url: "https://unpoly.com/api/up.cache.evict"
---
<nav aria-label="Unpoly docs">[All docs](https://unpoly.com/index.md) · [up.network module](https://unpoly.com/api/up.network.md)</nav>

# up.cache.evict([pattern])

[Evicts](https://unpoly.com/learn/caching.md#eviction) responses in the [cache](https://unpoly.com/learn/caching.md).

The server may also evict cache entries by sending an [`X-Up-Evict-Cache`](https://unpoly.com/api/X-Up-Evict-Cache.md) header.

## Example {#example}

Calling without argument will clear the entire cache:

```js
up.cache.evict()
```

To only remove some cache entries, pass a [URL pattern](https://unpoly.com/api/url-patterns.md):

```js
up.cache.evict('/users/*')
```

---

## Parameters {#parameters}

### [pattern] {#pattern}

(optional)

A [URL pattern](https://unpoly.com/api/url-patterns.md) matching cache entries that should be removed.

If omitted, the entire cache is evicted.

Type: string

