Precompressed Brotli File in Workers Static Asset is not decompressed properly
Previously I have been putting .js.br file in Cloudflare Pages (React+Vite, linked to git and run build script in Pages)
I'm migrating to Workers, but when I put the same file in public folder, even with _headers (same as when using Pages) set to:
when the file is fetched, I get jumbled Response instead of the normally decompressed js file. The Response Headers have the content-encoding : br and content-type : application/javascript
wrangler.jsonc:
In the local environment the file works.
Not sure what I'm missing here. Thanks in advance!
Edit: It seems the one in Pages has "Content-Length" header, while in workers there isn't any. Is there a way to ensure there is one?

6 Replies
I'm a little confused, you're requesting a Brotli file and getting Brotli back with the appropriate content-encoding header. That sounds correct?
Yes, but I'm using Unity so it seems that Content-Length header is also required. When I was using Pages it was there. Usually the response in Network tab is already decompressed.
Then I'd get
Can you share the url to test? Content-Length is generally not there for compressed content (which is fully spec compliant)
That error seems to just want CE br which you have
Chrome should be decompressing it though so wonder if it's actually bad data...
url sent in DM
For now I can put the game files in R2 and use them like this:
But is it a waste of workers resource to transform R2 like this every time? Correct me if I'm wrong but should static assets in worker itself be better?
Ok sorry just getting back to this
This is weird..
Ok I see... it's double-compressed
Guessing the Pages path makes it work due to o2o
But for Workers, we see the eyeball wants brotli and compress it :blobcatsweats:
You could disable brotli compression with a compression rule but I'm not sure that "solves" it, we may then omit the content-encoding header
I've tried it with both compression rule and header change. I doesn't seem to work. I seems I need to put it on R2 and use worker.