---
title: Purging a URL via the Fastly control panel
summary: null
url: >-
  https://www.fastly.com/documentation/guides/full-site-delivery/purging/purging-a-url
---

This guide describes how to use the _Purge URL_ option to purge a single URL via the Fastly control panel. You can also purge a single URL using the [Fastly API](https://www.fastly.com/documentation/reference/api/purging/#purge-single-url) and [CLI](https://www.fastly.com/documentation/reference/cli/service/purge/).

## Considerations

Note the following considerations about executing a URL purge:

- URL purges are unauthenticated by default. To require a valid Fastly API token for URL purges, configure your service to add a `Fastly-Purge-Requires-Auth` header to the client request:

  ```vcl context="sub vcl_recv { ... }"
  set req.http.Fastly-Purge-Requires-Auth = "1";
  ```

- URL purges are not logged by default. If your service has a [logging endpoint](https://www.fastly.com/documentation/guides/integrations/non-fastly-services/developer-guide-logging) connected, you can log URL purges to that endpoint by emitting log events in edge code. For example, in a CDN service, this code would log a query string-formatted log line with the service ID when a purge is received.

  ```vcl context="sub vcl_recv { ... }"
  if (req.method == "FASTLYPURGE") {
    log "syslog " + req.service_id + " my-log-endpoint :: event=purge&service=" + req.service_id;
  }
  ```

## Purging a URL

To purge a single URL, follow the steps below:

1.   Log in to the [Fastly control panel](https://manage.fastly.com).

2.   From the [**Home**](https://manage.fastly.com/home) page, select the appropriate service. You can use the search box to search by ID, name, or domain.

3. From the **Purge** menu, select **Purge URL**.

   ![a purge by url](/img/purge-url-example.png)

4. From the **Domain** menu, select [the domain](https://www.fastly.com/documentation/guides/getting-started/domains/working-with-domains/working-with-domains) on which your content resides. If the domain you select is a wildcard domain (e.g., `*.example.com`) the Subdomain field will appear.

5. If the **Subdomain** field appears, enter the subdomain to purge for the wildcard domain you've selected (e.g., `www`).

6. In the **Full URL path** field, enter the path to the content you'll be purging (e.g., `/example.jpg`). The Preview field displays the URL that will be purged.

7. _(Optional)_ Select the [Soft purge](https://www.fastly.com/documentation/guides/full-site-delivery/purging/soft-purges) checkbox to mark your content as outdated instead of deleting it from cache.

8. Click **Purge**.

## Forwarding purge requests

Single URL purges are processed by your Fastly service like normal requests. The purge takes effect when your service forwards the request to the readthrough cache layer.

In CDN services, request forwarding occurs by default, but can be obstructed if your code prevents the request being forwarded. Be sure that requests with a `FASTLYPURGE` method are not blocked.

In Compute services, HTTP `PURGE` requests must be forwarded explicitly by calling the relevant fetch method:

### Rust

```rust
use fastly::{Error, Request, Response};

#[fastly::main]
fn main(req: Request) -> Result {

  // Forward purge requests immediately to a backend
  if req.get_method() == "PURGE" {
    return Ok(req.send("any_backend_name")?);
  }

  // ... process normal, non-purge requests here

  Ok(Response::from_status(200))
}
```

### Javascript

```js
async function handleRequest(event) {

  // Forward purge requests immediately to a backend
  if (event.request.method === "PURGE") {
    return fetch(event.request, { backend: "any_backend_name" })
  }

  // ... process normal, non-purge requests here

}
addEventListener("fetch", (event) => event.respondWith(handleRequest(event)));
```

### Go

```go
package main

import (
  "context"
  "fmt"
  "io"

  "github.com/fastly/compute-sdk-go/fsthttp"
)

func main() {
  fsthttp.ServeFunc(func(ctx context.Context, w fsthttp.ResponseWriter, r *fsthttp.Request) {

    // Forward purge requests
    if r.Method == "PURGE" {
      resp, err := r.Send(ctx, "any_backend_name")
      if err != nil {
        w.WriteHeader(fsthttp.StatusBadGateway)
        fmt.Fprintln(w, err.Error())
        return
      }
      w.Header().Reset(resp.Header)
      w.WriteHeader(resp.StatusCode)
      io.Copy(w, resp.Body)
      return
    }

    // ... process normal, non-purge requests here

  })
}
```

### Cpp

In this version of the Fastly Compute C++ SDK, this behavior is not supported.

Currently, manually forwarding `PURGE` requests so that they are visible to the cache is the only way to enable URL purging in Compute services. For such requests, any backend can be used, since the request will not be forwarded beyond the cache layer.

> **HINT:** In Compute services, it's often better to use [surrogate keys](https://www.fastly.com/documentation/guides/full-site-delivery/purging/working-with-surrogate-keys/) to label cached objects.

> **IMPORTANT:** The HTTP method of `PURGE` requests is changed to `FASTLYPURGE` before the request is processed by CDN services. No such transformation happens in Compute services.

## Troubleshooting

If you're having trouble executing a URL purge, or if the purge appears to have no effect, check the following:

- **Hash algorithm:** If you changed your service's hashing algorithm (e.g. `vcl_hash` in CDN services), make sure that your purge request is causing the same lookup in cache as the request that caused the content to be cached.
- **Rewriting URL settings:** If your service configuration rewrites URLs, or changes any other property of the request in a way that affects the cache key, you may not be targeting it correctly.
- **Shielding settings:** If your service has shielding enabled, ensure that the request forwarded to the shield POP has the same request properties as the one originally received at the edge POP (i.e., a POP acting as an edge in a shielding configuration should avoid modifying the request).
- **Stale content settings:** If your purge was executed as a soft purge, your service may continue to serve the pre-purge content based on your [stale content settings](https://www.fastly.com/documentation/guides/full-site-delivery/performance/serving-stale-content/).

## What's next

Explore the other purging methods available with Fastly such as [purging with surrogate keys](https://www.fastly.com/documentation/guides/full-site-delivery/purging/purging-with-surrogate-keys) and [purging all content](https://www.fastly.com/documentation/guides/full-site-delivery/purging/purging-all-content).

## Related content

- [Purging best practices](https://www.fastly.com/documentation/guides/full-site-delivery/purging/purging-best-practices)
- [Image optimizer reference](https://www.fastly.com/documentation/reference/io/#purging-images-from-the-fastly-cache)
- [Purging API documentation](https://www.fastly.com/documentation/reference/api/purging/)
- [Purging CLI documentation](https://www.fastly.com/documentation/reference/cli/service/purge/)
