Closed petetak closed 5 years ago
In fact maybe the return value is not important as we are interested only in exceptions from the call to Cloudflare:
So perhaps a decent solution is to chunk the file list and make multiple calls to the Cloudflare api and then return true at the end of it?
Thanks @petetak - it will take a bit to review your suggestion. Please be patient.
No problem at all. FYI I've put this into production on a site and it's now not getting stuck on cache clear tasks (which it was before) and the upper-cache table is not as huge as it was.
I'll let you know if I run into any issues.
The API docs are ambiguous:
Zone error codes
1094 | Exceeded maximum amount of 500 files that can be purged on a single request
Purge Files by URL
(array) files max length: 30
And in the Cloudflare Control Panel under Caching > Custom Purge, they tell me the limit is 30.
You will need to specify the full path to the file. Wildcards are not supported with single URL purge at this time. You can purge up to 30 URLs at a time.
--
@petetak I'll go with 30, okay? This should not hurt even if the limit is 500.
That sounds great!
Cloudflare has a 500 url limit for cache invalidation so it would make sense to split the array into smaller chunks and call the api with these chunks.
https://github.com/ostark/upper/blob/b8a584a41d4a85f739770b144d380729fe7f7dd1/src/drivers/Cloudflare.php#L61
I'm happy to work on this and submit a PR but I don't want to change the interface to purgeUrls - ie: I'm not sure what it should return if I made this change.
If you let me know what you would like to do I'll work on it.