Skip to content

perf(registry): opt-in compression for JSON API responses - #1570

Open
ricardo-devis-agullo wants to merge 1 commit into
masterfrom
perf/registry-json-compression-opt-in
Open

perf(registry): opt-in compression for JSON API responses#1570
ricardo-devis-agullo wants to merge 1 commit into
masterfrom
perf/registry-json-compression-opt-in

Conversation

@ricardo-devis-agullo

Copy link
Copy Markdown
Collaborator

Problem: middleware/compression.ts only serves the pre-compressed oc-client static file (routes/static-redirector.ts). Batch POST / and discovery JSON responses - the largest payloads the registry serves - go out uncompressed (item 5, registry-performance-improvements.md).

Change: new opt-in registry option compression (boolean, default OFF so CDN-terminated deployments pay nothing).

  • Express adapter gains enableCompression() (standard compression() middleware, default 1KB threshold, gzip/deflate); wired in middleware.bind only when options.compression is true.
  • Option plumbed through options-sanitiser (defaults false) with JSDoc on Config.compression; adapter interface extended with optional enableCompression? so third-party adapters keep compiling.
  • Fastify: NOT mirrored - left as follow-up. @fastify/compress would need a new dependency plus adapter plumbing and parity testing; the optional interface method is the seam for it.

Verify:

  • New spec test/unit/registry-middleware-compression.js (6 tests): sanitiser defaults false/preserves true; JSON route returns identity with option off despite Accept-Encoding: gzip; gzip Content-Encoding + gunzip round-trip with option on; deflate round-trip; identity with no Accept-Encoding.
  • Payload sizes (100-component JSON fixture, 32906 bytes uncompressed): off -> identity 32906 for gzip/deflate/identity; on -> gzip 509 bytes (~65x), deflate 497 bytes, identity 32906.
  • Full packages/oc suite (npm run test-silent): 1103 passing, 0 failing.
  • Did NOT touch routes/index.ts, domain/repository.ts, version-handler.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant