Brotli - cached assets only or entire stream?

Is brotli compression only applied to cached assets or to the entire data stream from the origin server?

1 Like

https://support.cloudflare.com/hc/en-us/articles/200168396-What-will-Cloudflare-compress-

Already read that, so which is it, the entire stream or cached only?

I believe it is the entire stream.

I’m hoping that’s the case but would like to be certain, since I’m not caching html.

From
https://support.cloudflare.com/hc/en-us/articles/200168086-Does-Cloudflare-compress-resources-
Cloudflare applies brolti compression itself to the client so I would assume that it sends the entire https stream

Just got this response from CF support:
“All Speed features, encluding Brotli, are only being applied to assets cached at our Edge.”

The reason I sought this answer is to help determine whether it’s worth applying brotli precompression to my server (I’m already using gzip). And it may well be since the majority of the stream is uncached.

Are you talking about to your origin server as opposite to Cloudflare edge servers?
If so then there would be no point

Cloudflare only supports the content types gzip and None towards your origin server

Source

Though support has stated otherwise, I see not-cached pages being served with brotli (and it doesn’t seem to come from origin, as it turns to gzip if I turn brotli compression off on Cloudflare)

image

Well that’s interesting. Is this on an Enterprise plan?

No. Free plan.

Yes, seeing the same now that I checked. Waiting for a reply from support.

1 Like

Well either I’m a little slow (high possibility) or support is contradicting itself.
The way I interpret this response is that Cloudflare IS using brotli to serve uncached data (although they continue to say they’re not?).

“The content is not requested from your origin in Brotli (but it is in Gzip) and served in Brotli if the Accept-Encoding allows it.”

What am I missing?

So when Cloudflare contacts your origin server or hosting provider it only uses Gzip or uncompressed however when a client connects to Cloudflare it will that content in Brotli, Gzip or uncompressed.

Well, since we’re talking about uncached assets, that’s a contradiction to their first response:
“All Speed features, encluding Brotli, are only being applied to assets cached at our Edge.”

Some Cloudflare features only apply to cached assets. For instance, Polish. Let’s say you have a domain where Polish is enabled (Pro plan or higher). Polish will optimize images, but only the cached images will get it. So if a new visitor comes along, the Cloudflare datacenter will fetch the images from the origin and pass them on unmodified to the visitor, while at the same time saving a copy to the cache to which Polish optimization has been applied. So the next visitor will get that cached, optimized image.

I believe the support agent who helped you initially may have been under the impression that the same would apply to Brotli compression, when my testing (and now yours) shows otherwise. The second response from support only confirms that in my case Brotli was not applied at the origin, as Cloudflare would not have requested it anyway.

So, to answer your question about whether you should preprocess brotli compression at the origin, the answer is no. Cloudflare will only get gzipped or uncompressed sources out or your origin.

And this bit from the documentation @Cyb3r-Jak3 has linked to above says caching has no impact on the application of compression by Cloudflare:

Cloudflare’s reverse proxy is also able to convert between compressed formats and uncompressed formats, meaning that it can pull content from a customer’s origin server via gzip and serve it to clients uncompressed (or vice versa). This is done independent of caching.

1 Like

Yes, I believe the initial response was incorrect.
Here’s what I think is really happening, see if you agree.
All assets requested through Cloudflare, both cached and uncached, are delivered via brotli as long as the clients accept-encoding allows.

However, brotli requests to and from the origin server are ignored and served in gzip unless you have an Enterprise plan.

" If you enable the “Respect Strong ETags” page rule (Enterprise only feature), then we will preserve the visitor’s Accept-Encoding header when forwarding the request to the origin."

That seems to be right.

Perhaps you should email support one more time and give them a link to this topic, or else publish the ticket number here so that @cloonan may contact them about updating their response for similar issues (or correct us if our conclusion is somehow mistaken).

2 Likes

Ticket #: 04620106

So the bottom line: all Cloudflare plans except Enterprise, will get a partial benefit from brotli.

Apparently the compute cost for brotli is too high to extend the full benefits to the rest of us (Pro/Business).

1 Like

I did not notice plan type discussion on the ticket but will re-read for details.

I did see this Support reply & supporting cURLs from just shortly before the prior recent posts on this thread, “The content is compressed. The content is not requested from your origin in Brotli (but it is in Gzip) and served in Brotli if the Accept-Encoding allows it.”

1 Like