Not really possible through Cloudflare APIs. We don’t treat cached data like an AWS storage bucket for example and in each colo it’s entirely possible we’d have different assets cached. If you made a request for example.com/whats-new/ and the customer had (for example) cache everything set for that static assets all of the requests would be served from our cache if they were already cached. But we don’t have any type of index/map which would even allow you to say “purge all assets associated with the whats-new page” as each asset from the html page itself to each image on the page is stored according to its unique URI and we (mostly) do (dumb) pattern matching to the web requests we receive…
Oh you wanted https://example.com/images/upload/december/cool-logo.gif?
Do I have that in my cache already?
Is it expired?
Here you go.
Since we’re pulling from the origin itself we sort of don’t care what the overall site map/index looks like (unlike perhaps a push cache might). So there’s no way to really query our cache via API to see what objects are stored (there’d potentially be >100 different answers depending on what a given colo had.
So instead really the only indicator for the cache status for an object is from the particular colo you are querying for a particular URI. Here’s the cloudflare homepage (just the html bits and) response edited for clarity:
curl -I https://www.cloudflare.com
date: Tue, 21 Nov 2017 15:07:34 GMT
content-type: text/html; charset=utf-8
expires: Tue, 21 Nov 2017 19:07:34 GMT
cache-control: public, max-age=14400
In the above section the cf-cache-status indicates whether the object is cached (but only for the SFO colo which was the colo which served my request. On https://api.cloudflare.com/ you’ll see that we have a cache purge API where you could request a particular item (or group of items) be purged, but there’s no API to list individual items.
If I were building a Wordpress app to index the content I would probably look at communicating directly with the SQL database as all the meat is really stored there and can be queried relatively inexpensively.
Does that make sense?