Fastly purge api example?

Hi, am implementing some basic caching control for our Fastly cache, basically just purging some surrogate keys upon page updates, but since Fastly is a partner am wondering if there is already some example code I can look at for consuming the Purge API (https://docs.fastly.com/api/purge) that I can have a look at?

Litium version: 7.2

I have now created my own, will post it if someone here is interested.

1 Like

I have created a Powershell script as below that was used with Octopus deploy to flush specific surrogate keys of the Fastly cache during deploys.

$ServiceId = $OctopusParameters["ServiceId"]
$ApiKey = $OctopusParameters["ApiKey"]
$SurrogateKey = $OctopusParameters["SurrogateKey"]

$headers=@{
	"Fastly-Key"="$ApiKey"

	"Accept"="application/json"
}

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Invoke-WebRequest -Headers $headers -Uri https://api.fastly.com/service/$ServiceId/purge/$SurrogateKey -Method POST
1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.