Possible to purge a (worker) cache for a specific url globally?

We use workers to run our pages. They are cached for a few hours, but we plan to increase the total hours and purge the cache for a specific page once the content changes. Important to point out that 1) we need to purge the cache for a specific URL and 2) the page cache needs to be purged globally for all data centers. Right now, we are sending a POST request to the https://api.cloudflare.com/client/v4/zones/<zone_id>/purge_cache route, and adding the “prefix” and “files” to the body:

body: JSON.stringify({
   prefixes: [ my.url.com/path/otherpath ],
   files: [{ https: my.url.com/path/otherpath }]
})

We are doing this based on what we found on this page How the Cache works | Cloudflare Workers docs, but I’m not able to check the CF-Cache-Status (as described here ​Purge everything | Cloudflare Cache (CDN) docs). So, we get the success response, but I’m wondering if it’s supposed to be done like this or if we should do something different…

Yes, that’s how to do it. Note that you need an Enterprise plan to purge by prefix though. Since you are purging a specific file, just give the full URL in files. Also note the limits to the number of files per call and calls per day.

Thanks for the reply @sjr . Yep, we have an enterprise plan. You said we need to give the full URL in files for the specific file, but just to make sure we are on the same page: we want to clear the cache for a specific page url (not a specific file), so that the entire page (that is being generated on the server side with the nextjs app router) can be regenerated. For example, if you visit this page Mediterranean Diet: Food List & Meal Plan and check the network tab you’ll see the doc whose name is 16037-mediterranean-diet, but I can’t see a CF-Cache-Status there…that’s why I’m wondering if I’m doing something wrong by trying to purge the cache for that document.

If you have an Enterprise plan, you are ok with what you are doing.

I’m not a developer so not sure of the reason (maybe the cookie, maybe the browser using POST, etc), but as that doc doesn’t have a cf-cache-status header it isn’t being cached. Purging it anyway won’t cause any problems unless you hit any limits.