0
votes

Checking my website with Google Pagespeed Insights, I get the following warning:

Enable compression Compressing resources with gzip or deflate can reduce the number of bytes sent over the network. Enable compression for the following resources to reduce their transfer size by 2.9KiB (56% reduction). Compressing https://MY_BUCKET.storage.googleapis.com/logo.svg could save 561B (49% reduction).

It seems Google Cloud Storage does not have gzip enabled for svg's? How can I enable gzip compression also for svg file type?

1

1 Answers

3
votes

Turns out you have to manually compress the svg:

gzip -9 -S 'z' *.svg

and then upload it with the Content-Encoding:

gsutil -h "Content-Encoding:gzip" -h "Content-Type:image/svg+xml" cp logo.svgz gs://MY_BUCKET/logo.svgz

Source: https://cloud.google.com/storage/docs/gsutil/addlhelp/WorkingWithObjectMetadata#content-encoding

UPDATE:

This combines the two above commands, as mentioned by @jterrace

gsutil -h "Content-Encoding:gzip" -h "Content-Type:image/svg+xml" cp -Z logo.svg gs://MY_BUCKET/logo.svg