Setup push invalidation for Fastly
Push invalidation automatically purges content on the customer's production CDN (e.g. www.yourdomain.com), whenever an author publishes content changes or a developer pushes code changes to the main branch (changes on other branches do not trigger push invalidation).
Content is purged by url and by cache tag/key.
Push invalidation is enabled by setting up the Fastly purge credentials in the cdn section of the configuration service.
curl --request POST \
--url https://admin.hlx.page/config/{org}/sites/{site}/cdn.json \
--header 'content-type: application/json' \
--data '{
"prod": {
"host": "{production host}",
"type": "fastly",
"serviceId": "{serviceId}",
"authToken": "{authToken}"
}
}'
Configuration properties:
| key | value | comment |
host |
<Production Host> |
Host name of production site, e.g. www.yourdomain.com |
type |
fastly |
|
serviceId |
<Fastly Service ID> |
Service ID of production service |
authToken |
<Fastly API Token> |
To create a Fastly API Token,
- go to Personal API Tokens,
- click on "Create Token",
- enter a name (e.g.
"Production Site Purge Token"), - select "A specific service" and your production service from the drop-down list,
- check the "Purge select content (purge_select) — Purge by URL or surrogate key" check box,
- select "Never expire",
- click on "Create Token",
- copy the generated token value shown in the pop-up window.
You can validate the credentials with this tool.