Configure additional file formats for gzip/brotli compression

Hello,

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 netlify.app URL for your site.
gzip

$curl -s -H 'accept-encoding: gzip, deflate' https://preactjs.netlify.app/content/en/guide/v10/forms.md | wc -c
2172

brotli

$ curl -s -H 'accept-encoding: gzip, deflate, br' https://preactjs.netlify.app/content/en/guide/v10/forms.md | wc -c
1997

However using preactjs.com shows
gzip

$ curl -s -H 'accept-encoding: gzip, deflate' https://preactjs.com/content/en/guide/v10/forms.md | wc -c
2181

brotli (which isn’t brotli at all)

$ curl -s -H 'accept-encoding: gzip, deflate, br' https://preactjs.com/content/en/guide/v10/forms.md | wc -c
5473

You can also see the difference in Developer Tools → Network

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

Hm, indeed! Didn’t realize there was a netlify.app 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.

Thanks!

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:

/*.md
	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.