Skip to content

perf: add API response compression middleware #43

@snowrugar-beep

Description

@snowrugar-beep

Problem Statement

No response compression is configured. Large responses (gist lists with pagination with full content) could benefit from gzip/brotli compression to reduce bandwidth usage and improve mobile load times.

Evidence

  • No compression middleware in main.ts
  • Gist response includes full text content in every item

Impact

Larger bandwidth usage. Slower response times for mobile users with limited connectivity.

Proposed Solution

  1. Install compression middleware (compression npm package)
  2. Register in main.ts as Express middleware
  3. Configure for brotli with gzip fallback
  4. Exclude already-compressed responses

Technical Requirements

  • Must use accept-encoding negotiation
  • Must prefer brotli over gzip
  • Must not compress ALB health check responses
  • Must handle streaming responses correctly

Acceptance Criteria

  1. Response headers include Content-Encoding: gzip or br
  2. Response body is compressed (verify with curl --compressed)
  3. Health check responses are not compressed
  4. Response time for large payloads decreases
  5. All E2E tests pass

File Inventory

  • Backend/src/main.ts
  • Backend/package.json

Dependencies

None.

Testing Strategy

  • E2E test: verify Content-Encoding header
  • Performance test: compare response sizes with and without compression

Security Considerations

No security impact. Compression is safe for all response types.

Definition of Done

  • Compression middleware installed
  • Working with gzip/brotli
  • Tests passing

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions