Get Content-Length

I have a worker that returns a string as text/plain, in local dev I get the response with content-length, but not on the deployed worker. why?
15 Replies
Hello, I’m Allie!
At a guess, it may be another part of the Cloudflare CDN that adds that header?
Yigal
YigalOP8mo ago
🤔 But there's no routing, it's straight app.xxx.workers.dev, where would you check?
Hello, I’m Allie!
I don't think it is something you can toggle, if that is what you mean
Yigal
YigalOP8mo ago
So if I have old devices that require content-length, how would you serve them from a worker? I need to send a json, and preferrably not change the code on the devices
Hello, I’m Allie!
Actually, it looks like if you return JSON directly, it sets the content-length header automagically... Playground
Yigal
YigalOP8mo ago
I tried now, and the headers are totally different between local and deployment
No description
No description
Hello, I’m Allie!
What about on a custom domain?
Hello, I’m Allie!
Weird, I'm on FF too, and I get 71...
Yigal
YigalOP8mo ago
Ok, same code on playground, local dev and deployed. the deployed worker is the only one not giving away the content-length
No description
No description
No description
Hello, I’m Allie!
Just to check, your response has a content-encoding header, right? And, do you see a content-length on https://bangarang.goalastair.com/ ?
Yigal
YigalOP8mo ago
Yes, I have "conetnt-encoding: br" and I do see the content-length on the link you sent.
Hello, I’m Allie!
Looks like when a response is compressed, the content-length is removed. You just have to disable compression via a Compression Rule
Cloudflare Docs
Compression Rules · Cloudflare Rules docs
Use Compression Rules to customize the compression applied to responses from Cloudflare’s global network to your website visitors, based on the file …
Yigal
YigalOP8mo ago
Thanks. enterprise feature 😞
Want results from more Discord servers?
Add your server