Can I serve JSON with Gzipped with GitHub Pages?

I have a JSON file on GitHub pages, it is about 2 MB uncompressed. I access this file using the jQuery method $.get(). I would like a gzip file that compresses it to about 500 KB, but when I put the gzip file on GitHub pages, it $.get()does not work with an error:Uncaught SyntaxError: Unexpected token

I think the problem is that the GitHub pages do not set the header Content-Encoding: gzipin the JSON file, and the GET request considers that it is dealing with a simple JSON file. Is there any way:

  • Configure GitHub pages to add a header Content-Encoding: gzipto a file .json, OR
  • Configure the AJAX request so that it knows that it is dealing with a JSON file with gzipped, although the server did not tell it that the content is encrypted.
+4
source share
1 answer

Github pages are already gziping html, css, js, json, ... It is futile to try to do better with gziping json yourself.

1.3M json is sent as 357KB on github pages. See here and click the "download json" link.

+5
source

Source: https://habr.com/ru/post/1623011/


All Articles