When incoming requests match
-
Custom filter expression:
- Media Type equals
image/avif
OR - File extension equals
avif
- Media Type equals
Then
- Compression options > Disable compression
Create a compression rule to turn off compression for AVIF images, based on either the content type or the file extension specified in the request.
The following example rule will disable compression for AVIF images, based on either the content type or the file extension specified in the request.
When incoming requests match
Custom filter expression:
image/avif
ORavif
Then
The following example sets the rules of an existing entry point ruleset (with ID {ruleset_id}
) for the http_response_compression
phase to a single compression rule, using the Update a zone ruleset operation:
Required API token permissions
Response Compression Write
Config Settings Write
Dynamic URL Redirects Write
Cache Settings Write
Custom Errors Write
Origin Write
Managed headers Write
Zone Transform Rules Write
Mass URL Redirects Write
Magic Firewall Write
L4 DDoS Managed Ruleset Write
HTTP DDoS Managed Ruleset Write
Sanitize Write
Transform Rules Write
Select Configuration Write
Bot Management Write
Zone WAF Write
Account WAF Write
Account Rulesets Write
Logs Write
Logs Write
curl https://api.cloudflare.com/client/v4/zones/$ZONE_ID/rulesets/$RULESET_ID \ --request PUT \ --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \ --json '{ "rules": [ { "expression": "http.response.content_type.media_type eq \"image/avif\" or http.request.uri.path.extension eq \"avif\"", "action": "compress_response", "action_parameters": { "algorithms": [ { "name": "none" } ] } } ] }'