Purge cache of a single file using PHP (API)


Does anyone know how I can purge the cache of a single file using PHP? (API)

I would be very grateful for an example.

Thanks in advance.

You either use the HTTP interface directly, https://api.cloudflare.com/#zone-purge-files-by-url, or use the PHP abstraction library, https://github.com/cloudflare/cloudflare-php.


The first option is nothing I think, because I need it inside a php-script.

I think the second option is more for me.

Do you have an example for the second option how I can clear the cache for a single file?


You can still run it from your PHP code by simply issuing a respective HTTP request.

Google will probably have a few examples, otherwise simply refer to the API documentation.

1 Like