style
content

Setup push invalidation for Cloudflare

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 registering a Cloudflare purge token 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": "cloudflare",
		"plan": "enterprise",
		"zoneId": "{cloudflare_zone_id}",
		"apiToken": "{cloudflare_api_token}"
	}
}'

Configuration properties:

key value comment
host <Production Host> Host name of production site, e.g. www.yourdomain.com
type cloudflare
plan e.g. free

values: free, pro, business, enterprise

default: free

zoneId <Cloudflare Zone ID> ID of production zone
apiToken <Cloudflare API Token>

To create an API Token,

Note that only sites on the enterprise plan will be surgically purged by url and cache key. A Purge All will be performed instead on non-enterprise sites every time an author publishes a content change.

You can validate the credentials with this tool.