Skip to content

Serve compressed JavaScript and CSS from data.firefox.com #517

Open

Description

@stephaniehobson

Production serves JavaScript and CSS uncompressed. Every assets/ response from data.firefox.com comes back with no content-encoding, even though the browser offered gzip, br and zstd:

File On the wire today Gzipped (vite preview)
index-*.js 214 KB 71 KB
DashboardContainer-*.js 179 KB 68 KB
ChartContainer-*.js 268 KB 90 KB

On a slow 4G connection, the main script alone takes 1.76 s to download in production, against 0.97 s from a local gzipped build. Every step of a first visit waits on downloads like this one. This is the largest single cost found while measuring #516, and it lives in the deploy, not the app.

The transposer's JSON under datasets/ is uncompressed too.

Proposed fix

In .github/workflows/deploy.yml, upload text assets gzip-encoded:

gcloud storage cp --gzip-local-extensions=js,css,svg,html,json ...

This stores each object gzip-compressed, with Content-Encoding: gzip. Cloud Storage decompresses on the fly for the rare client that doesn't accept gzip.

To check

  • After a deploy to stage, check that curl -sI -H 'Accept-Encoding: gzip' <stage>/assets/index-*.js shows content-encoding: gzip, and that the site still loads in Firefox, Chrome and Safari.
  • Check that the CDN in front of the bucket (FORCE_CACHE_ALL, see docs/architecture/deploy.md) passes the encoding through and still serves deep links.
  • Ask the CDN/bucket owners in Data Engineering whether Cloud CDN's dynamic compression (brotli) can be turned on. That would also cover the transposer's JSON without any change to how it uploads.
  • Separately, the CDN rewrites cache-control to public,max-age=0 on content-hashed assets, so they're revalidated on every visit. That's worth raising in the same conversation.

Found while measuring #516.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions