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

Compression Rules

Use Compression Rules to customize the compression applied to responses from Cloudflare’s global network to your website visitors, based on the file extension and content type. Compression Rules are powered by the Ruleset Engine.

Cloudflare compresses some responses by default, based on the content type. With Compression Rules, you can customize the default behavior, which includes defining preferred compression algorithms for particular file types.

When there is a match for a compression rule configured with several compression algorithms, the selected algorithm is the first one supported by the website visitor, according to the received accept-encoding HTTP header. If multiple compression rules match, the last rule wins.

​​ Get started

Follow the instructions in the following pages to get started:


​​ Availability

Compression Rules are available to Enterprise customers.

FreeProBusinessEnterprise

Availability

NoNoNoYes

Number of rules

00010

​​ Relevant fields

The following fields are commonly used in expressions of compression rules:

​​ Important remarks

  • If there is a match for a compression rule but the client does not support any of the compression algorithms configured in the rule (according to the provided Accept-Encoding request header), the response sent to the client will not be compressed.

  • If there is a match for a compression rule but the response sent from the origin server contains a cache-control: no-transform HTTP header, the compression rule will not perform any changes to the response.

​​ Troubleshooting

When troubleshooting compression rules, use Cloudflare Trace Beta to determine if a rule is triggering for a specific URL.