Automate Cache Clear


#1

I have a client site built in WordPress that’s on the CloudFlare Business Plan. The site gets updates from a 3rd party site over night. After the import the cache is cleared via Automatic Cache Management. But there’s always a few pages whose cache isn’t cleared.

Is there a way to schedule clearing of cache? Since the site is using the WordPress plugin and WP CLI, is there a way to clear cache on cron run?


#2

Yep. Use ‘curl’ to hit the API:
https://api.cloudflare.com/#zone-purge-all-files


#3

If you want to keep things simple, you can do this with the Browser Cache Expiration and a Page Rule for Edge Cache TTL value in CloudFlare. So for example ‘every two hours’.
No need for extra software.


#4

I ended up using the purge cache by URL since there were only a handful of pages whose cache wasn’t being cleared through Automatic Cache Management
https://api.cloudflare.com/#zone-purge-files-by-url