Compress a binary blob served as worker asset

I have a binary blob that's served as worker asset as part of a react vite app. I want to compress it before it is sent as it can reduce the size by a lot. Apparently server on wrangler dev is compressing the blob but not when it is deployed to the worker. How can I compress it? The attached screenshots show the difference when it is served on localhost vs production
No description
No description
10 Replies
texan
texan•2mo ago
👀 the screenshots both look like they’re localhost
Yuu
YuuOP•2mo ago
oops i mispasted
Yuu
YuuOP•2mo ago
No description
Yuu
YuuOP•2mo ago
sorry for deleting and resending, had to censor the name of the worker
Hello, I’m Allie!
Is this with a custom domain? Idk if compression is enabled on the workers.dev zone
Yuu
YuuOP•2mo ago
no, not it's workers.dev. I can try it with a custom domain as well well, i'm getting it on localhost. which is what confuses me right. what I would expect to happen is worker returns a compressed blob that is then distributed by the CDN is that incorrect?
Hello, I’m Allie!
The other way around. The Worker returns an uncompressed blob, the CDN compresses and distributes it
Yuu
YuuOP•2mo ago
ah i see is there any way to force compression on these assets, like how localhost is doing?
Hello, I’m Allie!
Have you tried what Leo suggested, and give it a different content-type?
Yuu
YuuOP•2mo ago
yeah, cbor apparently isn't one of the types that is compressed by just setting the content-type, according to docs: https://developers.cloudflare.com/speed/optimization/content/compression/ the question now really is how I would be able to force the cbor to be compressed oh i see, thank you for pointing me to that

Did you find this page helpful?