Using Worker to invalidate all objects under an URL

I never used Workers before. Let's say I have an external domain example.com. Can I use workers to cache some resources under this domain. Can I use workers to invalidate all resources under this domain? Thanks
2 Replies
Chaika
Chaika5mo ago
Can I use workers to cache some resources under this domain
Sure, using the Cache API https://developers.cloudflare.com/workers/runtime-apis/cache/#put
Can I use workers to invalidate all resources under this domain?
The Cache API is local colo/datacenter only, and only has Delete and not Purgge. To invalidate everything, you'd need to purge everything in the Cloudflare API, which you could call from a Worker https://developers.cloudflare.com/api/operations/zone-purge
Cloudflare API Documentation
Interact with Cloudflare's products and services via the Cloudflare API
Cloudflare Docs
Cache · Cloudflare Workers docs
Control reading and writing from the Cloudflare global network cache.
Busslina
Busslina5mo ago
Thank you
Want results from more Discord servers?
Add your server