The response I’m getting is totally ok and I get success: true.
For some reason this doesn’t work 100% of the times though. I thought it was a matter of waiting but when it works the url is purged immediately. When it fails the url is not purged even after 10 minutes of calling the API.
I’m using the Cache API from a Worker and then using fetch to purge via the REST API.
The HTML is generated in the worker and put into the Cache API using some data from KV.
It’s not really a matter of debugging. I receive a correct response from the API and the result is the same when purging that URL from cloudflare’s dashboard. Sometimes it’s purged, sometimes it’s not.
Well, if you dont want to post the code it is difficult to say anything. Purging does seem to work, so I’d stick with the assumption of a race condition. You’ll have the debug that code, something is not writing the right data.
The data is being written to KV when it should. I have triple checked it.
The API response from the purge returns OK.
The same problem seems to happen randomly from Cloudflare’s dashboard too.
I’m not writing to the cache API when I’m doing the purge. The cache API is written when the URL is refreshed, just like a Workers Site project does. It doesn’t matter if you refresh 1 minute after the purge or 1 hour.
Where do you think the race condition could be happening?