Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google cloud storage console Content-Encoding to gzip

I am using Google Cloud Storage console to upload files. I am not using any command line tool. I want to Set the Content-Encoding to gzip (-z option) in Metadata.

Please see below screenshot, is value 'z' is correct or not?

enter image description here

I have set value 'z' for all css and js files, and analyzed webpage on PageSpeed Insights. PageSpeed Insights still telling me enable compression, please check below screenshot.

enter image description here

I am using Nginx webserver with HttpGzipModule installed on Debian 7.

Thanks.

like image 721
Hrishi Avatar asked Aug 16 '26 06:08

Hrishi


1 Answers

"-z" is a feature of the gsutil command line tool -- it compresses the data locally and uploads it to GCS with Content-Encoding: gzip. It is not a feature (or property) of the HTTP protocol or Google Cloud Storage, hence simply setting the header does not achieve what you are going for.

If you want to store (and serve) gzip-encoded data, you have two options:

  1. Apply gzip-compression locally, for instance with the gzip Unix tool. Then remove the .gz suffix from the file name and upload it with the "Content-Encoding: gzip" header and the appropriate Content-Type (e.g., "text/css" for css, "application/javascript" for js).
  2. Use the gsutil tool with the -z flag, and it will take care of all of the above for you.
like image 130
lot Avatar answered Aug 18 '26 19:08

lot



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!