Purging a URL via the Fastly control panel
- English
- 日本語
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 and CLI.
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-Authheader to the client request:sub vcl_recv { ... }Fastly VCLset req.http.Fastly-Purge-Requires-Auth = "1";URL purges are not logged by default. If your service has a logging endpoint 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.
sub vcl_recv { ... }Fastly VCLif (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:
- Log in to the Fastly control panel.
- From the Home page, select the appropriate service. You can use the search box to search by ID, name, or domain.
From the Purge menu, select Purge URL.

From the Domain menu, select the domain on which your content resides. If the domain you select is a wildcard domain (e.g.,
*.example.com) the Subdomain field will appear.If the Subdomain field appears, enter the subdomain to purge for the wildcard domain you've selected (e.g.,
www).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.(Optional) Select the Soft purge checkbox to mark your content as outdated instead of deleting it from cache.
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
- JavaScript
- Go
- C++
1234567891011121314use fastly::{Error, Request, Response};
#[fastly::main]fn main(req: Request) -> Result<Response, Error> {
// 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))}1234567891011async 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)));12345678910111213141516171819202122232425262728293031package 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
})}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 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_hashin 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.
What's next
Explore the other purging methods available with Fastly such as purging with surrogate keys and purging all content.