---
title: Purging
summary: >-
  Instant Purging removes content from Fastly immediately so it can be refreshed
  from your origin servers. While the default approach for issuing an individual
  URL Instant Purge uses the Fastly API, <code>https://api.fastly.com/</code>,
  it is not required.
url: https://www.fastly.com/documentation/reference/api/purging
---

Instant Purging removes content from Fastly immediately so it can be refreshed from your origin servers. While the default approach for issuing an individual URL Instant Purge uses the Fastly API, <code>https://api.fastly.com/</code>, it is not required.

Purging effectively removes an object from the Fastly cache, prompting future requests that would otherwise hit that cached object to proceed to origin as a cache miss.

In practice, while some types of purge do effectively delete content, others will mark the content as stale, allowing you to refresh caches more gracefully if desired. This kind of purge is called a _soft_ purge (see [soft vs. hard purge](https://www.fastly.com/documentation/reference/api/purging#soft-vs-hard-purge) below).

Learn more about how purging works, including use cases and best practices, limitations, constraints, and performance in our dedicated [purging overview](https://www.fastly.com/documentation/guides/concepts/edge-state/cache/purging).

## Soft vs. hard purge

By default, purging an object will make it immediately inaccessible to new requests.  The data might not be removed from storage right away, but it will no longer be matched by any cache lookup and will eventually be evicted.  This is a 'hard' purge.

For improved performance and to protect backend servers from being overloaded by an inrush of traffic following a purge, you can perform a 'soft' purge, which marks the affected object as stale rather than making it inaccessible.  The presence of stale objects can reduce backend load by allowing for conditional revalidation and other performance-enhancing patterns.  To learn more, read about [using and revalidating stale content](https://www.fastly.com/documentation/guides/concepts/edge-state/cache/stale/).

Single object, surrogate key, and bulk surrogate key purges all support soft purge.  To make a purge soft, add the following HTTP request header when making the API request:

```http
Fastly-Soft-Purge: 1
```

Purge-all requests cannot be done in soft mode and will always immediately invalidate all cached content associated with the service.  To do a soft-purge-all, consider applying a constant [surrogate key](https://www.fastly.com/documentation/guides/full-site-delivery/purging/working-with-surrogate-keys/) tag (e.g., `"all"`) to all objects.

## Data model

| Field | Type | Description |
|-------|------|-------------|
| `surrogate_keys` | array |  |
| `id` | string | Alphanumeric string identifying a Purging. (Read-only) |

## API endpoints

### Purge a URL

**POST** `/purge/{cached_url}`

Instant Purge an individual URL.

**Parameters:**

| Name | Type | In | Required | Description |
|------|------|----|---------|--------------|
| `cached_url` | string | path | Yes | URL of object in cache to be purged. |
| `fastly-soft-purge` | integer | header | No | If present, this header triggers the purge to be 'soft', which marks the affected object as stale rather than making it inaccessible.  Typically set to "1" when used, but the value is not important. |

### Purge everything from a service

**POST** `/service/{service_id}/purge_all`

Instant Purge everything from a service.
Purge-all requests cannot be done in soft mode and will always immediately invalidate all cached content associated with the service. To do a soft-purge-all, consider applying a constant <a href="https://www.fastly.com/documentation/guides/full-site-delivery/purging/working-with-surrogate-keys/">surrogate key</a> tag (e.g., <code>"all"</code>) to all objects.

**Parameters:**

| Name | Type | In | Required | Description |
|------|------|----|---------|--------------|
| `service_id` | string | path | Yes | Alphanumeric string identifying the service. |

### Purge by surrogate key tag

**POST** `/service/{service_id}/purge/{surrogate_key}`

Instant Purge a particular service of items tagged with a Surrogate Key. Only one surrogate key can be purged at a time. Multiple keys can be purged using a batch surrogate key purge request.

**Parameters:**

| Name | Type | In | Required | Description |
|------|------|----|---------|--------------|
| `fastly-soft-purge` | integer | header | No | If present, this header triggers the purge to be 'soft', which marks the affected object as stale rather than making it inaccessible.  Typically set to "1" when used, but the value is not important. |
| `service_id` | string | path | Yes | Alphanumeric string identifying the service. |
| `surrogate_key` | string | path | Yes | Surrogate keys are used to efficiently purge content from cache. Instead of purging your entire site or individual URLs, you can tag related assets (like all images and descriptions associated with a single product) with surrogate keys, and these grouped URLs can be purged in a single request. |

### Purge multiple surrogate key tags

**POST** `/service/{service_id}/purge`

Instant Purge a particular service of items tagged with surrogate keys. Up to 256 surrogate keys can be purged in one batch request. As an alternative to sending the keys in a JSON object in the body of the request, this endpoint also supports listing keys in a <code>Surrogate-Key</code> request header, e.g. <code>Surrogate-Key: key_1 key_2 key_3</code>.

**Parameters:**

| Name | Type | In | Required | Description |
|------|------|----|---------|--------------|
| `fastly-soft-purge` | integer | header | No | If present, this header triggers the purge to be 'soft', which marks the affected object as stale rather than making it inaccessible.  Typically set to "1" when used, but the value is not important. |
| `service_id` | string | path | Yes | Alphanumeric string identifying the service. |
| `surrogate-key` | string | header | No | Purge multiple surrogate key tags using a request header. Not required if a JSON POST body is specified. |
