Skip to content

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.

Free Pro Business Enterprise

Availability

No

No

No

Yes

Number of rules

0 0 0 10

Relevant fields

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

Field in Expression BuilderField name
Media Typehttp.response.content_type.media_type
File extensionhttp.request.uri.path.extension
N/Araw.http.request.uri.path.extension

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 to determine if a rule is triggering for a specific URL.