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:
- Getting the current version of a page including headers via Curl
- Sending the purge request and ensuring we get a Success response
- 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:
- Check the cf-cache-status is MISS
- 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.