I m confused it seems to be possible to
I'm confused, it seems to be possible to either purge by key locally or purge all assets globally. Is it possible to purge by key globally?
15 Replies
Currently, it is not possible to purge a URL stored through Cache API that uses a custom cache key set by a Worker.Your best bet is global purge but you can do by hostname
Is it possible to fan out a request so that it gets executed on all edge nodes? Perhaps that is what I want because then I can manually purge just the cache key that I want to purge.
From my understanding that purge url is for all nodes where as the
cache.delete
in on the same datacenterWhat do you mean by the "purge url"? You mean this URL
https://api.cloudflare.com/client/v4/zones/ZONE_ID/purge_cache
Yeah sorry using the API url
I thought you were saying that the URL above is for the web CDN cache. While the internal worker cache API is a completely separate mechanism?
I misread the docs
Are you sure? Because after reading the docs I think that you were correct before.
Cache · Cloudflare Cache docs
Cloudflare makes customer websites faster by storing a copy of the website’s content on our servers. Caching static resources at Cloudflare reduces your server load and bandwidth, with no extra charges for bandwidth spikes
https://developers.cloudflare.com/workers/learning/how-the-cache-works/#purging-assets-stored-with-the-cache-api
To purge an asset globally, you must use the standard cache purge options. Based on cache API implementation, not all cache purge endpoints function for purging assets stored by the Cache API. All assets on a zone can be purged by using the Purge Everything cache operation. This purge will remove all assets associated with a Cloudflare zone from cache in all data centers regardless of the method set. Available to Enterprise Customers, Cache Tags can be added to requests dynamically in a Worker by calling response.headers.append() and appending Cache-Tag values dynamically to that request. Once set, those tags can be used to selectively purge assets from cache without invalidating all cached assets on a zone.
Yes, I've seen this. I'm not sure how that changes anything? Sorry about the back and forth, I must be missing something.
The middle part. Regardless of the method set includes cache API
Sure, but that is just a button on the Cloudflare UI that deletes everything from the cache. I want to just delete a key but delete it from all edge nodes. The API URL (
https://api.cloudflare.com/client/v4/zones/ZONE_ID/purge_cache
) still seems to delete from the Cloudflare CDN not the workers cache.I don't think that is possible
Currently, it is not possible to purge a URL stored through Cache API that uses a custom cache key set by a Worker
The CDN cached is the one called by the Cache API