Cache revalidation using Cache Tags
I came across a very impressive feature by Netlify (cache revalidation using cache tags). We cache something in a CDN (1 year) by tagging it with some custom cache tag. Then, for example, from a CMS after a post update, we purge the data with exactly the tags we need. Can we reproduce similar behavior on Cloudflare using the Purge Cached Content HTTP endpoint (for Free or Pro plans)?
https://developers.cloudflare.com/api/resources/cache/methods/purge/
Netlify Astro Example:
I currently have a project with a headless WordPress setup that uses the cache-control
https://developers.cloudflare.com/api/resources/cache/methods/purge/
Netlify Astro Example:
src/pages/books/[slug].astro:src/pages/api/webhook.json.ts:I currently have a project with a headless WordPress setup that uses the cache-control
stale-while-revalidate (it's custom varnish + nginx), but this is not ideal for a CMS. I keep ttl short enough (1-10 seconds) so that the user sees the update as early as possible without overloading the origin server and have some cached responses at high load.Interact with Cloudflare's products and services via the Cloudflare API