PHP Client for Cloudflare API
Cache

Variants

Variant support caches images with certain file extensions separately per MIME type, so an origin serving `webp` to one client and `jpeg` to another does not have them collapsed into a single cached copy.

Variant support caches images with certain file extensions separately per MIME type, so an origin serving webp to one client and jpeg to another does not have them collapsed into a single cached copy.

Get

Current variant support setting for a zone.

ParamTypeRequiredDefaultDescription
zoneIdstringYesZone Identifier.
php
$response = $client->cache()->variants()->get('ZONE_ID');
View this operation on the Cloudflare API Reference

Edit

Set the variants cached for a zone.

Keyed by file extension — avif, bmp, gif, jpeg, jpg, jpg2, jp2, png, tif, tiff, webp — each holding the MIME types to serve as variants of it:

$client->cache()->variants()->edit('ZONE_ID', [
    'jpeg' => ['image/webp', 'image/avif'],
    'png'  => ['image/webp'],
]);
ParamTypeRequiredDefaultDescription
zoneIdstringYesZone Identifier.
valuearrayYesVariants to cache, keyed by file extension.
php
$response = $client->cache()->variants()->edit('ZONE_ID', []);
View this operation on the Cloudflare API Reference

Delete

Revert variant support to its default, caching no variants.

ParamTypeRequiredDefaultDescription
zoneIdstringYesZone Identifier.
php
$response = $client->cache()->variants()->delete('ZONE_ID');
View this operation on the Cloudflare API Reference
Copyright © 2026