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
At a guess, it may be another part of the Cloudflare CDN that adds that header?
🤔 But there's no routing, it's straight app.xxx.workers.dev, where would you check?
I don't think it is something you can toggle, if that is what you mean
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
Actually, it looks like if you return JSON directly, it sets the
content-length
header automagically...
PlaygroundI tried now, and the headers are totally different between local and deployment
What about on a custom domain?
I'll try. meanwhile in the playground it's always content-length 42 for me
https://workers.cloudflare.com/playground#LYVwNgLglgDghgJwgegGYHsHALQBM4RwDcABAEbogB2+CAngLzbMutvvsAsAjAGwAcnAKwB2AJwBmThIAMvbkP5ChE7vzFjeQgExreALg5HjbHgOHips+YuWr1mnXoCwAKADC6KhACm37AAiUADOMOjBUNBe+iQYWHgExCRUcMA+DABEUDQ+AB4AdABWwRmkqFBgfqnpWTkFxRlunt5+ENgAKnQwPjFwMDBgUADGBFBeyIVwAG5wwUMIsBAA1MDouOA+bm55YUgkuD6ocOAQJADergCQs3RUQ7E+EEMAFgAUCD4AjiA+wRAANCQ-FNAUMILkAJTnK6XCD0aGXRGVU74QgkBgkBGIy6YlJpAD6vlyEBiGXc5IpGX+MMRmLgKTAdGgQ2CMSo4DA1OxOJIwT8uHxYHQAHNWckOVzsZi-h8ns82RKaZcAL40mmykAIKgkABKvzCVD5RWCXleqLgEKIMOVJBGcpIrx8CAQmChF2xGq1yR8AHddfqvHzXgByACizswMWDJCWQIjCHyaWCwTgwp8lutV2V1OVVrcJgLRjMglEkmkcgUShUag0Wl0-F4TS8vn8QVC4UiYyoMTiOHNpDxNTShHNpViFSqaUyZCFZEaHmbrQ6XR6JD6A2Go3GxS8W1cZwyQ3QwHg0DIFUidHxqJ8GX0GW0Mm0nGwMgkr5EVMPx9PUHPgwgK9UDAVMSn0ABtDIqDWHxinxI8TwIDIAF1-gyYA4GyfFVnWSo71qA56hKZV80LMiWGLCwy2sSs7BrRx614Zg3CAA
actually only in FF..
Weird, I'm on FF too, and I get 71...
Ok, same code on playground, local dev and deployed. the deployed worker is the only one not giving away the content-length
worker here https://player-text.playshield.workers.dev/
Just to check, your response has a
content-encoding
header, right?
And, do you see a content-length
on https://bangarang.goalastair.com/ ?Yes, I have "conetnt-encoding: br" and I do see the content-length on the link you sent.
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 …
Thanks. enterprise feature 😞