Cloudflare Docs
Rules
Rules
Edit this page
Report an issue with this page
Log into the Cloudflare dashboard
Set theme to dark (⇧+D)

Disable compression for AVIF images

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:

    • Media Type equals image/avif OR
    • File extension equals avif

Then

  • Compression options > Disable compression

​​ Example API request

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:

curl --request PUT \
https://api.cloudflare.com/client/v4/zones/{zone_id}/rulesets/{ruleset_id} \
--header "Authorization: Bearer <API_TOKEN>" \
--header "Content-Type: application/json" \
--data '{
"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" }
]
}
}
]
}'