We try to keep requests and responses as-is as much as possible. Compression seemed like something we should do to prevent thousands of apps implementing their own.
Hmm, you might still want to set the Vary header here. We’re not caching anything, but if something upstream does, then it should vary by content-encoding.
FYI, if you’re considering promoting this to a supported feature, an example of how others do it: The folks at Cloudflare key off of Cache-Control: no-transform to disable features like gzip, image minification, etc (their docs).
(We found this out the hard way when their frontends were stripping our etags, a consequence of one of those rewriting features…)
I think you misunderstand. In order for you to gzip a response you have to wait for that response to complete from the origin. That means that the user has to wait for the full length of the response. I have tested this on Fly.io.
content-encoding: none does fix the problem, thanks.
I’d be happy to share a minimal reproduction so you can see the problem this causes. On all text/html responses you should not buffer the response in order to gzip it. For statics that’s fine, but not responses coming from the origin.
Enabling gzip by default has security implications (the BREACH attack). Maybe compression should be an opt-in feature, at least for non-static content?
Sorry, I think there’s some confusion here so let me just back up a second @kurt@jerome
HTML streaming is where you can respond to an HTTP request with chunks of html like:
<li>1</li>
Wait 5 seconds
<li>2</li>
Wait 5 seconds
etc. And the user will see 1 right away.
On Fly.io if you attempt to use this feature of the web it does not work. Instead the user sees nothing for, in this example, 10 seconds until the response is fully complete.
That is the bug. For me it is fixed by setting content-encoding: none. From @kurt’s reply it sounds like you think that gzipping is not happening, but it is happening, and the fact that it’s happening is the problem.
Ok, hope that clarifies the issue so that we’re all on the same page about what the problem is. Happy to discuss any solution (or no solution) from here.
We’re going to try to reproduce on our end and come up with a solution.
What’s the expected behaviour in your opinion? Is it possible to do gzip compression with streaming chunks in general (I haven’t yet done the research)?
I don’t think Vary is the problem here. That’s used for caching and we don’t cache anything.
I have a tentative fix in progress. Do you have a live app I can reproduce the issue with? Or a some code I can use in an app of my own to test the fix?