Cloudflare is decompressing my mapbox vector tiles

My website contains a Mapbox web map for which I host some Mapbox Vector Tile .pbf files. These files are natively GZip compressed so on my apache host server I add the Header “Content-Encoding: gzip”

As these are static files I added them to the Cloudflare cache using a page rule.

It seems that when Cloudflare caches these files it un-gzips them and then serves them uncompressed to the browser.

For example, if I fetch a .pbf file directly from my server its file size is 629.46 kB file but the transfer is only 315.86 kB (this matches the actual file size on my server). If I request the same file via Cloudflare it is a 629.46 kB file with a transfer size of 630.3 kB.

Is there a way to tell Cloudflare to no unzip these files and just keep them as they originally were?

1 Like

Add the no-transform directive to your Cache-Control header.


Compression is disabled when the no-transform directive is present. If the original asset fetched from the origin is compressed, it is served compressed to the visitor. If the original asset is uncompressed, compression is not applied.

1 Like

I tried adding it but then I just got “500 Internal Server Error” on all my requests

Can you provide an example URL?

Are you adding no-transform on all files, or just the .pbf files, with something like this:

<Files "*.pbf">
  Header set Content-Encoding: gzip
  Header set Cache-Control "max-age=63072000, public, no-transform"

My mistake, I’d made a typo. It now working. Thanks fo your help.

1 Like

No prblm.

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