Skip to content
This repository was archived by the owner on Oct 17, 2026. It is now read-only.

Compress the SPA's bundles and the API's JSON in nginx - #228

Merged
skearnes merged 1 commit into
mainfrom
compress-assets-and-api
Oct 6, 2026
Merged

skearnes merged 1 commit into
mainfrom
compress-assets-and-api

Conversation

@skearnes

@skearnes skearnes commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

Summary

  • nginx.conf turns gzip on but sets no gzip_types, so nginx compresses only text/html. On the live site, index.html is gzipped, while the 929 KB JS bundle, the CSS, and JSON API responses such as /api/datasets (19.8 KB) go out uncompressed.
  • This compresses them. The load balancer in front passes responses through as they are, so nginx is the only place it can happen.

Changes

  • ord_interface/nginx.conf: gzip_types for text, CSS, JavaScript, JSON, XML, SVG, and WebAssembly; gzip_proxied any for the API; gzip_min_length 1024; gzip_vary on; gzip_comp_level 6. The search-results download is application/gzip and already compressed, so it is left out.

Testing

  • nginx -t passes in nginx:alpine.
  • Served from the SPA root in nginx:alpine with this config: the production JS bundle 929 KB → 202 KB, plus CSS, JSON, and index.html, all Content-Encoding: gzip with Vary: Accept-Encoding. The Cache-Control headers are unchanged, and a request without Accept-Encoding gets the plain file.
  • Level 6, measured with zlib (which nginx uses) at every level: JSON's ratio levels off there, 41× at level 5, 55× at 6, and 63× at 8 at half the speed, on a 1,536-reaction dataset. The bundle reaches 4.5× at 5 and 4.6× from 6 on.

Notes

  • The proxied path was not exercised here, since the API listens on a unix socket in the image. ord-app#839 tested the same gzip_proxied any and application/json settings through a proxied route.
  • Takes effect on the next deploy from ord-infrastructure's interface stack.

🤖 Generated with Claude Code

RetriggerConfidence Score: 5/5

The PR appears safe to merge.

What we checked:

  • Downloads stay compressed once: The download route returns application/gzip, which is not included in gzip_types.
Summary

Enables gzip for SPA assets and JSON API responses in nginx.conf.

  • Adds compression level 6, a 1 KB minimum, and compression for proxied responses.
  • Adds Vary: Accept-Encoding and keeps the existing cache policy.
  • Leaves already-compressed search downloads out of the configured types.
  • No actionable issues found. No runtime tests were run during this review.

Reviews (1) · Last reviewed commit: "Compress the SPA's bundles and the API's..."

nginx.conf turned gzip on but set no gzip_types, so nginx compressed only
text/html: the 929 KB JS bundle, the CSS, and every JSON API response
went out uncompressed. It now compresses text, CSS, JavaScript, JSON,
XML, SVG, and WebAssembly over 1 KB, including proxied responses, at
level 6, with Vary: Accept-Encoding.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@skearnes
skearnes merged commit 1953940 into main Oct 6, 2026
16 checks passed
@skearnes
skearnes deleted the compress-assets-and-api branch October 6, 2026 23:39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant