Discussion about adding brotli compression to Sanity's CDN
24 replies
Last updated: Mar 4, 2021
C
Any thoughts about supporting brotli as well as gzip?
Mar 2, 2021, 2:13 AM
N
I’ll have a look at how we can support it, thanks for the tip!
Mar 2, 2021, 6:27 AM
C
Sweet, could be as easy as your CDN settings :)
Mar 2, 2021, 6:31 AM
N
You would think that 😄 Of course Google CDN leaves compression to the servers behind it, and my particular server version is still waiting for brotli support. I'll keep an eye on it though!
Mar 2, 2021, 9:25 AM
C
Cheers Nicolas :)
Mar 2, 2021, 9:26 AM
C
Especially funny since Brotli is from google 😂
Mar 2, 2021, 9:27 AM
N
Hm our apicdn might be able to support brotli, would that be interesting? Or are you on the api primarily?
Mar 2, 2021, 10:10 AM
C
Yeah we’re on CDN :)
Mar 2, 2021, 10:33 AM
N
It's working in staging! https://txmoes4e.apicdn.sanity.work/v1/data/query/production?query=%5B*%5B_id%20in%20%5B%2[…]e%2CreleaseDate%2Cposter%2CcastMembers%7D%5D%5B0...1%5D
We'll do some testing and plan a release of the change
😄
We'll do some testing and plan a release of the change
😄
Mar 2, 2021, 10:43 AM
N
*content-encoding:* br
Mar 2, 2021, 10:44 AM
C
Holy crap, fastest feature request I ever saw.
Can you do draft ref draft and inline new referenced document next
😂😂😂❤️❤️❤️
Can you do draft ref draft and inline new referenced document next
😂😂😂❤️❤️❤️
Mar 2, 2021, 10:45 AM
C
Thanks y’a legend Nicolas :)
Mar 2, 2021, 10:45 AM
C
We’re starting a performance bash in 12hrs and you’re already getting wins on the board for us ❤️❤️❤️⭐️⭐️⭐️
Mar 2, 2021, 10:46 AM
N
Haha! Nice 😄 ❤️
Mar 2, 2021, 10:46 AM
N
Love to be distracted by nice shiny features 😉
Mar 2, 2021, 10:47 AM
C
🏃♂️💨
Mar 2, 2021, 10:47 AM
C
Well if it was that easy to speed up sanity CDN by up to a quarter I’d say it’s a pretty sweet distraction!
Mar 2, 2021, 10:48 AM
N
and it's live! Look for
*content-encoding:* brin the response headers 😄
Mar 3, 2021, 8:34 AM
C
Nice!!! Thanks Nicholas.
Mar 3, 2021, 8:34 AM
N
Let me know if there are more infra features we can do 😉
Mar 3, 2021, 8:35 AM
C
You know it :) <3
Mar 3, 2021, 8:39 AM
C
ooooh, can we do it for SVGs too? Definitely already compressing more on the graphql CDN 🙂, a random example query i just did got 6% smaller
Mar 3, 2021, 10:04 PM
C
Also interested in what kind of perf timing diff you’re seeing. Its possible it could be a slower first call and faster subsequent calls, very interested in how it impacts your times 🙂
Mar 3, 2021, 10:19 PM
N
I added brotli for svg's too!
https://cdn.sanity.io/images/qtzcw0t9/production/11f5bbfe343cb8371f867403de78ba05a13c213b-604x640.svg?h=240&q=80&fit=max&auto=format&dpr=1
https://cdn.sanity.io/images/qtzcw0t9/production/fcfc79bf6bd24ac15a0f1e70dc3d05ed4237ba29-306x240.svg?h=240&q=80&fit=max&auto=format&dpr=1 Perf timing is negligible, this is solved when our varnish cache fetches upstream, so you're really getting an image transformation at the same time, the extra 1 ms at that point is nothing. It's stored as brottli compressed inside varnish, and transcoded to gzip if client does not support brottli.
https://cdn.sanity.io/images/qtzcw0t9/production/11f5bbfe343cb8371f867403de78ba05a13c213b-604x640.svg?h=240&q=80&fit=max&auto=format&dpr=1
https://cdn.sanity.io/images/qtzcw0t9/production/fcfc79bf6bd24ac15a0f1e70dc3d05ed4237ba29-306x240.svg?h=240&q=80&fit=max&auto=format&dpr=1 Perf timing is negligible, this is solved when our varnish cache fetches upstream, so you're really getting an image transformation at the same time, the extra 1 ms at that point is nothing. It's stored as brottli compressed inside varnish, and transcoded to gzip if client does not support brottli.
Mar 4, 2021, 11:22 AM
C
Very cool. Seeing a range of not much to 15% smaller depending on the svg for us in prod. Thanks again Nicholas!
Mar 4, 2021, 11:36 AM
Sanity– build remarkable experiences at scale
Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.