Enable gzip compression for files
Why is this change being made?
Our HTML assets aren't being served compressed because our Google Cloud Storage bucket doesn't know that compressing them is okay. In addition, we have a custom Fastly rule that skips caching of HTML files, so Fastly never gets a chance to gzip them either.
We use the -z option (patched with
https://github.com/GoogleCloudPlatform/gsutil/pull/1430 via
gitlab-org/gitlab-build-images!472 (merged))
to tell Google that certain files can be uploaded compressed. See
https://cloud.google.com/storage/docs/gsutil/commands/cp for more
details.
Relates to https://gitlab.com/gitlab-com/gl-infra/infrastructure/-/issues/14852
For example:
$ curl -v -s -o /dev/null -H "Accept-Encoding: gzip" https://sh-adding-gzip-encoding.about.gitlab-review.app/index.html |& grep content-
< x-goog-stored-content-encoding: gzip
< x-goog-stored-content-length: 37067
< content-type: text/html
< content-encoding: gzip
< content-length: 37067
Notice content-type is text/html but content-encoding is gzip. Compare this:
$ curl -v -s -o /dev/null -H "Accept-Encoding: gzip" https://about.gitlab.com/ |& grep -i content-
< x-goog-stored-content-encoding: identity
< x-goog-stored-content-length: 151627
< content-type: text/html
< content-length: 151627
Author Checklist
-
Provided a concise title for the MR -
Added a description to this MR explaining the reasons for the proposed change, per say-why-not-just-what - Copy/paste the Slack conversation to document it for later, or upload screenshots. Verify that no confidential data is added.
-
Assign reviewers for this change to the correct DRI(s) - If the DRI for the page/s being updated isn’t immediately clear, then assign it to one of the people listed in the "Maintained by" section in on the page being edited.
- If your manager does not have merge rights, please ask someone to merge it AFTER it has been approved by your manager in #mr-buddies.
-
If the changes affect team members, or warrant an announcement in another way, please consider posting an update in #whats-happening-at-gitlab linking to this MR. - If this is a change that directly impacts the majority of global team members, it should be a candidate for #company-fyi. Please work with internal communications and check the handbook for examples.
Edited by Stan Hu