---
name: "up.cache.expire"
area: "API"
kind: "JavaScript function"
parent: "up.network module"
url: "https://unpoly.com/api/up.cache.expire"
---
<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.expire([pattern])

[Expires](https://unpoly.com/learn/caching.md#expiration) entries in the [cache](https://unpoly.com/learn/caching.md).

Expired entries remain in the cache, but will be [revalidated](https://unpoly.com/learn/caching.md#revalidation) after rendering.

By default, Unpoly automatically expires the entire cache whenever it sends a request with a non-GET HTTP method. To customize this rule, use [`up.network.config.expireCache`](https://unpoly.com/api/up.network.config.md#config.expireCache).

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

## Example {#example}

Calling without argument will mark the entire cache as expired:

```js
up.cache.expire()
```

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

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

---

## Parameters {#parameters}

### [pattern] {#pattern}

(optional)

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

If omitted, the entire cache is expired.

Type: string

