Configure additional file formats for gzip/brotli compression


For Preact’s Docs site, we distribute the page content largely by markdown (*.md). However, it’s come to my attention that this is not being compressed by Netlify and there’s no obvious way to configure this. Compression for markdown is an absolute no-brainer, with 10kb+ savings on some of the larger pages.

How can we enable this?

I did a little testing based on this post. I also took a stab at the URL for your site.

$curl -s -H 'accept-encoding: gzip, deflate' | wc -c


$ curl -s -H 'accept-encoding: gzip, deflate, br' | wc -c

However using shows

$ curl -s -H 'accept-encoding: gzip, deflate' | wc -c

brotli (which isn’t brotli at all)

$ curl -s -H 'accept-encoding: gzip, deflate, br' | wc -c

You can also see the difference in Developer Tools → Network

So assuming the URL is correct then it is not Netlify that is stopping the serving of brotli but Cloudflare which is proxied through. If you haven’t read it before, check out

Hm, indeed! Didn’t realize there was a URL.

Unfortunately that linked post is a bit tone deaf when it comes to the necessity of Cloudflare and dropping it is definitely off the table. Will have to figure out what’s causing compression to fail on CFs end then.


Found it, Cloudflare (for some reason) still only recognizes the text/x-markdown content type and Netlify serves text/markdown. Quick enough of a fix using a _headers file:

	Content-Type: text/x-markdown

So why use Netlify then? If you need to use Cloudflare why not deploy to Cloudflare Pages and cut Netlify out of the equation? Makes sense to me.