What will Cloudflare compress?
In addition to Cloudflare’s CDN caching static content and auto-minification of CSS, JS & HTML to speed up your site, Cloudflare also provides gzip and brotli compression to help site owners.
Cloudflare will return gzip or brotli encoded responses to compatible clients / browsers for the following content-types:
text/htmltext/richtexttext/plaintext/csstext/x-scripttext/x-componenttext/x-java-sourcetext/x-markdownapplication/javascriptapplication/x-javascripttext/javascripttext/jsimage/x-iconimage/vnd.microsoft.iconapplication/x-perlapplication/x-httpd-cgitext/xmlapplication/xmlapplication/xml+rssapplication/vnd.api+json application/x-protobuf application/jsonmultipart/bagmultipart/mixedapplication/xhtml+xmlfont/ttffont/otffont/x-woffimage/svg+xmlapplication/vnd.ms-fontobjectapplication/ttfapplication/x-ttfapplication/otfapplication/x-otfapplication/truetypeapplication/opentypeapplication/x-opentypeapplication/font-woffapplication/eotapplication/fontapplication/font-sfntapplication/wasmapplication/javascript-binast application/manifest+json application/ld+jsonapplication/graphql+jsonapplication/geo+json
If you do not want a particular response from your origin to be encoded, you can disable this by setting cache-control: no-transform
at your origin web server.
Does Cloudflare compress resources?
Yes, Cloudflare applies gzip and brotli compression to some types of content. We also gzip items based on the browser’s UserAgent to help speed up page loading time.
If you’re already using gzip we will honor your gzip settings as long as you’re passing the details in a header from your web server for the files.
Cloudflare only supports the content types gzip towards your origin server and can also only deliver content either gzip compressed, brotli compressed, or not compressed.
Cloudflare’s reverse proxy is also able to convert between compressed formats and uncompressed formats, meaning that it can pull content from a customer’s origin server via gzip and serve it to clients uncompressed (or vice versa). This is done independently of caching.
Enable Brotli compression
By default, Brotli is enabled for domain on Free and Pro plans and disabled for domains on Business and Enterprise plans.
- Log in to the Cloudflare dashboard, and select your account and website.
- Click the Speed app.
- Click the Optimization tab.
- Toggle the Brotli switch to On.