The website encoding is broken on Safari

Hey, folks! There is seems to be an encoding issue that's only related to Safari, the "homepage" doens't load with the proper encoding, https://serce.me/. At the same time, the website loads fine from Chrome. It's a nextjs app, https://github.com/SerCeMan/SerCeMan.github.io, that's deployed to Cloudflare Pages.
SerCe's blog
SerCe's blog
SerCe's blog: Here is my personal blog where I share my thoughts and experiences with different technologies.
28 Replies
SerCe
SerCeOP4mo ago
An empty redeployed fixed the issue. No, unfortunately some pages are still broken on safari
sabercoy
sabercoy4mo ago
this is due to cloudflare ignoring Accept-Encoding headers and returning zstd encoded files you should be able to fix this by adding a Compression Rule in cloudflare console and turn off zstd at the end of the day its a cloudflare bug I hope they recognize
Chaika
Chaika4mo ago
Would have to see the response to be sure, but my understanding is the root of that issue is caused by enabling "Strong Etags" in a cache rule
sabercoy
sabercoy4mo ago
In my case, I never enabled this.
Chaika
Chaika4mo ago
do you have the headers of a wrong response? the only ones I've seen on the forums were from that and that's what CF Support said as well when they looked into it, would be interesting to see otherwise
sabercoy
sabercoy4mo ago
you can see at the URL firecrits.com
Chaika
Chaika4mo ago
I haven't messed around with etags too much but it does look like the images subdomain has strong etags on
sabercoy
sabercoy4mo ago
well the images (from r2) are one thing, I am more concerned with the JS files compressed with zstd and becoming unparsable by safari
Chaika
Chaika4mo ago
The js resources at least on the front page look proper with weak etags, but still if you've got it on for some of the assets then perhaps you enabled it more, would be worth a check through your rules, both Cache Rules and Page Rules have the Strong ETags Option
sabercoy
sabercoy4mo ago
keep in mind also, some JS files compress correctly, some are zstd, you may need to look for them if the page is loading white with no styles its because a JS file is broken, Safari even shows an error in the console saying a character or something cant be parsed
SerCe
SerCeOP4mo ago
Thanks, I should've captured a HAR. I definitely didn't touch any config, but all of the sudden the page started breaking on Safari without any redeployments. A redeploy solved plus clearing the caches solved the issue. Oh no! I was able to reproduce it just now, here's the HAR file in case it's useful @Chaika But yes, that's exactly it, zstd, when gzip, br is requested Looks like this is clearly a bug
Studio Smith-Cordell
I've been having similar issues
Gertas
Gertas4mo ago
We've been discussing this issue here https://community.cloudflare.com/t/zstd-serving-to-safari-no-solutions-for-free-plan/820998/37 (it's been happening to me for the last 10 days...), please add your findings there! Hopefully someone from Cloudflare is reading that thread
SerCe
SerCeOP4mo ago
Thanks, added my findings
Chaika
Chaika4mo ago
Thanks, that is helpful, I forwarded it. We've reported this a few times but I think there's been some trouble with reproing it exactly That looks like next on pages? Wonder if it returning a response from the Worker like that is related at all,h mm
Gertas
Gertas4mo ago
I'm also using nextjs btw, if that helps... maybe it is related to it specifically? Nevertheless, I've tried going between two major versions (13 and 15) and it breaks on both, so it's not one specific nextjs version
Chaika
Chaika4mo ago
It could be related to the way it's making/returning responses, although there's def been examples without nextjs headers, you'd be using the same next-on-pages adapter regardless of the nextjs version so
Gertas
Gertas4mo ago
Ah sorry, I didn't know that next-on-pages is a specific CLI tool (just googled it), thought you meant just "using nextjs on Cloudflare" in general I'm using statically exported nextjs uploaded to Cloudflare Pages through Wrangler actually
Chaika
Chaika4mo ago
yea then that's fully static and points to it just being some generic issue with the way Pages Custom Domains work (orange to orange), like was thought before. Well, hopefully they can get to the bottom of it soon
Gertas
Gertas4mo ago
Makes sense, and yeah, hopefully...
nestorF
nestorF4mo ago
@Chaika are you able to reproduce this issue currently?
Chaika
Chaika4mo ago
I can't currently no, if we repro consistently this would be a lot easier
nestorF
nestorF4mo ago
Thank you, we have escalated this to our engineering team for further investigation
Studio Smith-Cordell
It's not NextJS related. I've had the issue on two client sites using SvelteKit
flimble
flimble4mo ago
@SerCe can you let us know as soon as you see it again, as I currently can't reproduce, or see a known way this should currently happen for this url/zone ah, if you cleared caches and hadn't since the incident on the status page was resolved, you may have had a lingering cached zstd object
SerCe
SerCeOP4mo ago
Yeah, if the caches weren't cleared, then this could've been the culprit. I assume there are others who've got incorrect responses stuck in caches, though.
Studio Smith-Cordell
Just wondering whether the fix means that those of us who switched Zstd off can turn it back in so that browsers that do support it can benefit again. Is this feature no longer sending Zstd to Safari users?

Did you find this page helpful?