Purge Fastly CDN cache instantly using surrogate keys

domain: fastly · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Tag cacheable origin responses with the Surrogate-Key header (space-separated list of logical keys, e.g., product-123 category-shoes); Fastly stores the association between these keys and cached objects without exposing the header to end clients
  2. To purge all objects associated with a surrogate key, send a POST request to https://api.fastly.com/service/<service-id>/purge/<surrogate-key> with the Fastly-Key header containing your API token; this purge is near-instant and propagates globally within seconds
  3. To purge multiple surrogate keys in one API call, use the bulk purge endpoint: POST to https://api.fastly.com/service/<service-id>/purge with a JSON body {'surrogate_keys': ['key1','key2']} and the same Fastly-Key header
  4. To purge a single URL (by path), send POST https://api.fastly.com/purge/<host>/<path> with the Fastly-Key header; this is slower to set up for programmatic use — prefer surrogate key purges for content-type-level invalidation
  5. Design your surrogate key taxonomy around content identity: use object IDs for precise invalidation, entity-type keys for broader sweeps (e.g., purge all product listings), and a global key for full-site purges during deployments
  6. Rotate API tokens used for purging separately from tokens used for configuration changes; use a token scoped to purge only (Engineer role with purge scope) to limit blast radius of a compromised credential

Known gotchas

Related routes

Invalidate CloudFront cached content and tune cache key configuration for efficient caching
aws-cloudfront · 6 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans