Question

I'm accessing JSON files stored in a bucket on Google Storage directly using an AJAX request. However to optimize the communication I want to enable gzip encoding.

The docs say I have to send an Accept-Encoding header and an altered User-Agent (containing gzip). Accept-Encoding is no problem, however altering your User-Agent is not possible, the w3c even specifies so.

How can I still enable gzipping while doing these request?

Was it helpful?

Solution

If you'd like to download your files with gzip encoding, they need to be stored in Google Cloud Storage with that encoding already applied, as well as with the appropriate metadata (Content-Encoding: gzip and proper content type, in this case Content-Type: application/json). If you subsequently request these objects with the Accept-Encoding: gzip request header, GCS will serve them with gzip encoding.

Edited to add: "gzip" in the user agent string is no longer required (but doesn't hurt either) -- I've requested that the docs be updated accordingly.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top