PMTiles icon indicating copy to clipboard operation
PMTiles copied to clipboard

GitHub pages hosting .pmtiles not always working? (Chrome/Firefox)

Open bdon opened this issue 6 months ago • 9 comments

Discussed in https://github.com/protomaps/PMTiles/discussions/582

Originally posted by jamaps June 15, 2025 Hi y'all

I've been using GitHub pages to host smaller .pmtiles (<50mb or so) for the past few months (and mostly loading and styling them in maplibre). Has been working great!

But recently I'm seeing that .pmtiles files hosted via Github pages are sometimes not loading and returning errors like this in my web browser:

  • In Chrome, Error: Server returned no content-length header or content-length exceeding request. Check that your storage backend supports HTTP Byte Serving.

  • In Firefox, "Decoding failed."

My projects still work perfectly fine when testing locally and loading local files, or when loading .pmtiles coming from anywhere else other than a GitHub repo.

Anyone know if GitHub pages has changed how they serve .pmtiles or similar files that rely on range requests? or have any other ideas?

(Noticing as well that Chrome seems to not error as much compared to Firefox, but I don't really understand why there would a browser difference).

Thanks!

~ Jeff

bdon avatar Jul 01 '25 04:07 bdon

This is the line that fails:

https://github.com/protomaps/PMTiles/blob/main/js/src/index.ts#L460

Something changed in the GitHub Pages HTTP implementation related to Content-Encoding

bdon avatar Jul 01 '25 04:07 bdon

https://github.com/orgs/community/discussions/162857 may also be related

bdon avatar Jul 01 '25 04:07 bdon

Here is my current understanding of the problem:

Firefox is unique in that it sends the following HTTP header along with Range:

Accept-Encoding: gzip, deflate, br, zstd, identity

Other browsers such as Safari and Chrome only send Accept-Encoding: identity.

Something recently changed in GitHub Page's Fastly CDN configuration meaning that the server responds with an Content-Encoding: gzip on 206 responses if gzip is present in Accept-Encoding. This means no PMTiles hosted on GitHub Pages will work in Firefox.

Because we cannot control Accept-Encoding in the client, the only fix I see is to prove that the new GitHub pages behavior is incorrect. I think the best approach may to be make a very minimal reproduction of the problem using raw fetch requests and no PMTiles at all.

bdon avatar Jul 08 '25 07:07 bdon

I have created an independent reproduction of the issue here:

https://github.com/bdon/ghpages-firefox-range-bug

@jamaps

bdon avatar Jul 09 '25 02:07 bdon

Great to see this issue, here's a larger reproducible example: https://pctni.github.io/uitest/

Result on Firefox (with debugging FYI):

Image

On Chrome, all fine:

Image

Robinlovelace avatar Jul 29 '25 09:07 Robinlovelace

Will try deploying on Netlify.

Robinlovelace avatar Jul 29 '25 09:07 Robinlovelace

When served by netlify the same codebase renders fine on Firefox: https://pctnitest.netlify.app/

Robinlovelace avatar Jul 29 '25 09:07 Robinlovelace

@Robinlovelace @jamaps a temporary workaround to fix on Firefox is to rename .pmtiles to .pmtiles.gz. That will stop GitHub Pages from applying automatic compression.

In this long term I am hoping to get this merged into the MIME type database Pages uses, which ought to fix the problem: https://github.com/jshttp/mime-db/pull/398/files

bdon avatar Aug 04 '25 06:08 bdon

@bdon thank you! the workaround is working for me - hopefully that PR gets merged in soon

jamaps avatar Aug 13 '25 22:08 jamaps