Cloudflare doesn't respect the `Cache-Control` tag despite documentation

(Apologies for the URL formatting, I don’t have enough points or something to post them directly.)

TL;DR: How to coerce a Cloudflare proxy *not* to compress resource transfers as br or gzip, and just let them pass-through?


Hi all, so I’ve got two domains:

  • https://islandstorage.z33.web.core.windows.net/
    This is an Azure static site containing the website.

  • https://island.mblinov.net/
    This is the URL that I’d like to actually point my users to.

Now, the static site files have been pre-compressed by an external tool into .gz files (In this case, Unity game engine.)

If I open the “Network” panel in my browser and look at the transfers happening when I access the Azure static site directly, I can see that Build/build-island-optimized-webgl-azure-compressed.data.gz triggers a 4.08 MB transfer.

However, if I then access the site from the ‘pretty’ url, I can see that same file take up 4.11 MB.

Now I agree that it isn’t much, but from the response headers, I can see that Cloudflare apparently re-compressed the data as br.

I understand from the documentation here1, that one should be able to inform Cloudflare to disable this behavior by setting Cache-Control header to no-transform - I’ve done this (as you can see from the Azure endpoint), but Cloudflare doesn’t seem to care very much.

Is there something else I could try?

Maxim

A small mistake in the above post:

Build/build-island-optimized-webgl-azure-compressed.data.gz

should be

Build/build-island-optimized-webgl-azure-compressed.wasm.gz

Another weird formatting bug (I can’t edit my post, sorry): The link to the documentation is here:

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

Update on the situation: I’ve decided to just migrate my app fully to Azure Static Web Apps - so far everything “just works”, but I’d still like to get Cloudflare to work someday.

The biggest issue standing in the way of Unity WebGL builds, is the tag requirements. There are 4 core files that make up a given WebGL build:

  • Build/myproject.data.gz: Must be returned with content-type: octet-stream, content-encoding: gzip
  • Build/myproject.framework.js.gz: Must be returned with content-type: application/javascript or text/javascript, content-encoding: gzip
  • Build/myproject.loader.js: Doesn’t need any particular tags, just a plain javascript file.
  • Build/myproject.wasm.gz: Must be returned with content-type: application/wasm, content-encoding: gzip

I had a lot of issues getting all of this to work in Apache, Nginx, and Cloudflare. The Unity WebGL builds are extremely picky about the Content-Type header, and will refuse to continue running if something isn’t exactly right.

Azure seems to *sniff* out the contents and sets the Content-Type to the right thing in each case, but I’m still wary that one day it’ll stop working after an update, and I’ll have to go in and probably set it in a filter somewhere.

BTW: I didn’t originally deploy it on the Static Web Apps platform - Initially, I just used the Azure Blob storage + web hosting feature, which is basically like https:// accessible buckets. However you can actually set the Content-Type and Content-Encoding tags on the blob objects, so its possible to make it work that way - but then, if you have your domain name on Cloudflare (like I do), you don’t really have an easy way to redirect your Cloudflare DNS with no proxy directly to the Azure blob storage URL, because there is no HTTPS certificate for the Azure blob storage domain, and the browser complains about it.


I feel like I’m making this way more complicated than it should be, but I still haven’t got a setup that I’m fully happy with:

  • Cloudflare would have been ideal (I can drag-and-drop my folder without requiring it be hosted in Git), but it mangles the Content-Type and Content-Encoding headers.
  • Azure blobs let me drag-and-drop files into it, but don’t let me easily set the domain name
  • Azure Static Web Apps do everything, but requires me to upload via a nontrivial Github Action rule (So now I can’t just drag-and-drop - I have to make a commit, push it, and wait for all the Github Action machinery to do its thing before I can see the results.)

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