Pre-Compressed Assets in Pages

From https://blog.cloudflare.com/cloudflare-pages-ga/

Gzip and Brotli: Even smaller assets, such as HTML or JavaScript can benefit from compression. Pages will now serve content compressed with gzip or Brotli, based on the type of compression the client can support.

While we’ve been offering compression for a long time now (dating all the way back to 2012), this is the first time we’re able to pre-process the assets, at the time of the build step, rather than on the fly, resulting in even better compression.

I am trying to figure out how this works as I would like to compress using Brotli Level 11 (by default, CF dynamically compresses to Brotli Level 4). I tried putting an index.html and index.html.br in the same folder but it did not work. Anyone know how to get Pages to respond with pre-compressed assets?

You cannot choose the compression level. Brotli already gives very good compression and this is done during build on Cloudflare’s servers so I understand them not adding more load for a marginal benefit.

There isn’t a way to respond with pre-compressed assets on Pages (again, the benefit would be marginal anyway)
You could use Workers Sites I guess and serve the brotli files if the client supports it. Workers have 100,000 requests a day for free. The paid plan starts at $5 for 10,000,000 requests and 50 cent per million after.

Why does the Pages announcement say this then? It seems to indicate there is some way for Pages to respond with pre-compressed assets, even though, I agree, there is no documentation on it. Workers and Worker Sites already can do this of course, but this announcement is all about Pages.

I would need to ask the team but I believe it’s just referring to the fact Pages will compress during build time and serve those. I do not know the level it uses though. You don’t need to supply your own either which is what I meant wasn’t supported.

Let me message the team though and ask about it. I would also suggest joining the Discord where the team (and many other users) are active. You can find that here: Cloudflare Workers

Pages will compress during build time and serve those

This is not what Pages is doing on my test site. If I turn off Brotli in the main Cloudflare settings, files are shipped gzipped instead (which is default for Cloudflare, I reckon).

Thanks so much for messaging the team on it. I’ll check out the Discord, didn’t know it existed!

EDIT: Actually, it may be possible that they are pre-compressing and storing during build. But the compression level looks to be 4, which is the same as the dynamic compressing CF does normally. So… still confusion w.r.t. that announcement…

Alright, I have checked with the team and confirmed that yes, it is compressed during build and is still level 4.

Haha. It was one of the reasons I decided to give Pages a try.

-1 to Ms. Rita, but +1 to Mr. Walshy.

Thank you, case closed.

Be nice to Rita. She puts in a ton of hard work to do amazing things at Cloudflare.

1 Like

Yeah, sorry - I made a list of things before I decided to test out Pages (and also Workers/Worker Sites as a result). One of the reasons was Brotli Level 11, as some of my end-users are in low-bandwidth areas. Rabbit hole, for a straight day, checking all the boxes, only to find out this is not the case. Bummer, but also a slip in overselling the product maybe?

I will message Rita and let her know, so at least she can fix it if it needs fixing. :slight_smile:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.