Cache purging via the API - returning previously cached content despite success

We run a number of Wordpress sites on Cloudflare and want to start ensuring more of our content is cached. We have built a service that queues content updates and requests cache purges via the Cloudflare API which appears to be working. To test we are doing the following:

  1. Getting the current version of a page including headers via Curl
  2. Sending the purge request and ensuring we get a Success response
  3. Getting the updated version of a page including headers via Curl

We then check a number of things to determine whether the cache purge has been successful:

  1. Check the cf-cache-status is MISS
  2. Check the age - if it is < 10 seconds or doesn’t exist flag that as purged

If the cache status returns HIT or the age is > 10 seconds we class that as a failed purge.

Almost all of our purges are returning as successful HOWEVER, despite this when checking the page contents of some URLs they are actually identical to the previously cached version. It would appear that Cloudflare is returning cached content even though it says it is going to the origin server.

This can persist for up to 20 minutes despite multiple purge calls.

We can confirm that the content has updated on the origin by either disabling the Page Rule that says Cache Everything OR by adding a query string which then does return the correct content. Even with subsequent cache purge requests Cloudflare continues to return the cached content with updated headers.

I feel I’m missing something obvious.

Any ideas?

You’re seeing when Cache Status is MISS?

Purge by URL almost always shows SUCCESS. But it doesn’t mean the URL you think you purged was actually purged.

Hi @ColinP. I am experiencing the same issues. Did you manage to fix yours?