Is it possible to Purge URLs via Cloudflare Workers?

I am using Cloudflare’s cache everything page rule, coupled with WP-Rocket. Everything is working great, except, it’s also caching sitemaps. So whenever I update or publish a new post, the sitemaps won’t update.
Whitelisted sitemap in WP-rocket and also set to always purge for sitemap wherever a post is updated or published.
The sitemap still does not update sometimes.
I have used up all the 3 page rules for bypassing the wp-admin and login page.

Is there a way to use Cloudflare Workers to purge the CF cache for a few URLs whenever a post is published and updated?

Calling Cloudflare’s Purge Cache API inside the Workers should work.

https://api.cloudflare.com/#zone-purge-files-by-url

The challenging part is, how do you ensure that the Workers script only triggers when you do some update on your post, that’s something you need to figure out.

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