1

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?

Community
  • 1
  • 1
Joris Blaak
  • 398
  • 2
  • 10
  • Just to clarify, are you trying to download those objects or access their metadata /list them/etc? – Brandon Yarbrough Mar 26 '14 at 19:36
  • Doesn't your user agent already contain gzip? All modern browsers should. – jterrace Mar 26 '14 at 19:46
  • jterrace, browsers' user agent strings don't generally include "gzip" -- you might be thinking of the accept-encoding header which pretty much always has gzip listed nowadays – lot Mar 27 '14 at 05:15

1 Answers1

0

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.

lot
  • 1,045
  • 1
  • 8
  • 8
  • The docs seemed to imply that they'll apply gzip compression for you, I'll experiment with gzipping the files myselves. Hopefully they update the docs soon! – Joris Blaak Mar 27 '14 at 07:26