Brotli compression in the web

I was reading this article about a Rails Rubygem to do Brotli compression

and started reading up on it.

I checked using this link: GZIP Compression Test | GiftOfSpeed
that crystal-lang.org doesn’t enable it (at least accessing it from the library I was in).

I was also wondering if the Crystal web apps|servers enable it.
It seems it’s technically superior for web streaming, and maybe something to create a native Crystal implementation for.

3 Likes

Brotli is awesome for html/css etc web assets. On a few projects I’ve been able to use it to cut significant load time off projects.

Since Google provides libbrotli, I see no reason why it should be implemented from scratch in Crystal but linking in the C code would make a nice simple addition. It would be nice to get it for free in stdlib HTTP simply for how many projects would benefit but I’m not sure what the core teams philosophy is on that kind of thing these days.

1 Like

Haven’t tried it but there’s bindings here: GitHub - naqvis/brotli.cr: Crystal bindings to the Google brotli compression library

1 Like

As an application of Crystal toward a real world (useful) task, it would be at least an intellectually curious exercise to see how idiomatic Crystal code would compare to the reference C code (in size and readability, performance, memory, etc). It would be a nice person|team project just to learn|apply Crystal to a nontrivial problem if nothing else, for peole with the time to devote to it.

But every example of Crystal being used to do real stuff in a “better” way can only enhance its status, and answer the perennial question people ask (of any language really) - What’s it good for?